CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

External clock not working on 18LF24k22

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
alen12



Joined: 14 Mar 2014
Posts: 6

View user's profile Send private message

External clock not working on 18LF24k22
PostPosted: Thu Sep 04, 2014 2:08 pm     Reply with quote

I am using 18LF24k22 and I get garbage on my serial rs232 but if I switch it to internal oscillator everything works ok. Anyone can help me here. I checked my hardware and everything looks ok. I replaced 22pf capacitors and also my 8MHZ crystal but no difference. I am using CCS compiler and HSM for fuse. I also put a scope on my crystal and read 50ms which is low frequency so confused.

Code:

#include <18lf24k22.h>
#DEVICE ADC=10
#fuses HSM, NOWDT, NOLVP, NOBROWNOUT
#use delay(clock=8M)

thanks,
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 04, 2014 2:33 pm     Reply with quote

Use these fuses:
Code:
#fuses HSM, NOWDT, NOLVP, PUT, BORV29, NOPLLEN

The BORV29 fuse assumes you are running the PIC at 3.3v.
alen12



Joined: 14 Mar 2014
Posts: 6

View user's profile Send private message

PostPosted: Thu Sep 04, 2014 2:43 pm     Reply with quote

IT WORKED THANK YOU, I HAVE BEEN SPENDING LOTS OF TIME YOU SAVED ME ALOT, THANK YOU
alen12



Joined: 14 Mar 2014
Posts: 6

View user's profile Send private message

PostPosted: Thu Sep 04, 2014 2:49 pm     Reply with quote

where do you find fuses with their explanation what is their use?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 04, 2014 3:01 pm     Reply with quote

First, I took your fuses and made a short test program and compiled it.
Then I looked at the bottom of the .LST file and saw the PLLEN fuse.
I knew that you wanted to run at 8 MHz from a crystal. So no PLL was
needed. I then looked at the list of fuses at the top of the 18F24K22.h
file and confirmed that the one I needed was in the list, NOPLLEN.

If you have the IDE version of the compiler (PCWHD, etc), look for the
fuses.txt file in the CCS directory.
Ttelmah



Joined: 11 Mar 2010
Posts: 19552

View user's profile Send private message

PostPosted: Fri Sep 05, 2014 1:28 am     Reply with quote

The critical thing is where PCM_programmer looked at the LST file to see what fuses are set.

Never assume a fuse will be 'off' by default. Many won't.

If you literally compile your header, with a minimum program, the fuses listed in the .LST are:
Code:

Configuration Fuses:
   Word  1: F300   HSM PLLEN PRIMARY FCMEN IESO
   Word  2: 3C18   PUT NOBROWNOUT BORV19 NOWDT WDT32768
   Word  3: BF00   CCP2C1 PBADEN CCP3B5 HFOFST TIMER3C0 CCP2B5 MCLR
   Word  4: 0081   STVREN NOLVP NOXINST NODEBUG
   Word  5: C003   NOPROTECT NOCPB NOCPD
   Word  6: E003   NOWRT NOWRTC NOWRTB NOWRTD
   Word  7: 4003   NOEBTR NOEBTRB


Now a lot have defaulted to the safe setting (code protection etc.), but as you see, 'PLLEN' has defaulted to enabled....
alen12



Joined: 14 Mar 2014
Posts: 6

View user's profile Send private message

PostPosted: Fri Sep 05, 2014 11:58 am     Reply with quote

GOT IT, I THOUGHT AFTER I SWITCH IT TO EXTERNAL CLOCK I WOULD GET RIDE OF GARBADGE OVER SERIAL BUS, BUT ONCE A WHILE WITH JUST MY "mA" READING I GET GOOFY CHARACTERS. DO YOU KNOW WHAT COULD CAUSE THAT?
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Fri Sep 05, 2014 12:12 pm     Reply with quote

I can't tell if you are using software or hardware uart for the serial. If it is the software uart, then any interrupts going off during character send (bit banging) will cause "goofy" characters to be sent.

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
alen12



Joined: 14 Mar 2014
Posts: 6

View user's profile Send private message

PostPosted: Fri Sep 05, 2014 1:41 pm     Reply with quote

I am using hardware uart
temtronic



Joined: 01 Jul 2010
Posts: 9246
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Sep 05, 2014 2:53 pm     Reply with quote

'goofy characters' possible causes
1) bad wiring
2) bad connector
3) bad power supply
4) bad interface chips
5) use of internal oscillator
6) out of spec xtal/caps combo
7) use of sw UART
8) not using ISR with buffer
9) EMI
10) UARTs out of spec ( >3% error on speeds).

Without seeing your code, it's a toss of a 10 sided coin.

Show us a small program that shows the problem. The phrase about 'mA reading' leads me to believe you have a 'big, clunky' program.
Start small, simply send data from PC to PIC, then back to PC via UART. It should run 100% error free at 115k200 baud all day long.

hth
jay
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group