|
|
View previous topic :: View next topic |
Author |
Message |
Guest
|
18f2520 internal oscillator 16mhz pll enabled rs232 |
Posted: Mon Sep 05, 2005 8:25 am |
|
|
i have problem with an 18f2520 running at 16mhz, the rs232 doesn't work
#include <18F2520.h>
#device adc=8
#fuses HS,NOWDT,NOMCLR,INTRC_IO,NOLVP,NOPBADEN,NOBROWNOUT
#use delay(clock=16000000)
#use rs232(baud=38400,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=9)
oscilator setup:
#asm
MOVLW 0x60
MOVWF 0xFD3
MOVLW 0b11000000
MOVWF 0xF9B
#endasm
the rs232 does not work at all, however the pic boots and apparantle is running at 16mhz.
what to do? |
|
|
StuartH
Joined: 19 Aug 2005 Posts: 14 Location: W. Midlands, UK
|
|
Posted: Mon Sep 05, 2005 12:59 pm |
|
|
Thw 2520/4520 series has some silicon problems. I suggest you read the Silicon Errata document available on the Microchip website to see if any of the information is applicable to you.
As you seem to be using 9 bit mode, you might well be running into one of the documented issues. Check. |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Mon Sep 05, 2005 1:01 pm |
|
|
From the manual
Quote: | - 8 user selectable frequencies, from 31 kHz to 8 MHz |
So there is no way to get 16MHz using the HS fuse. You would have to configure the osc to 4MHz and use the H4 fuse. CCS provides a setup_oscillator() function. You will probably need to look in the readme file to see how you use it. I believe that it will do the same as your asm routine. Also, do you really need 9 bit data for the RS232? |
|
|
Ttelmah Guest
|
|
Posted: Tue Sep 06, 2005 4:51 am |
|
|
You need to read the data sheet. The PLL, when used with the internal oscillator, _is not_ configured by the fuses, but by setting the PLLEN bit, once the code is running.
So setup the fuses like:
#include <18F2520.h>
#device adc=8
#fuses NOWDT,NOMCLR,INTRC_IO,NOLVP,NOPBADEN,NOBROWNOUT
#use delay(clock=16000000)
#use rs232(baud=38400,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=9)
Then at the start of the code, have:
setup_oscillator(OSC_4MHz | OSC_PLL_ON);
Best Wishes |
|
|
|
|
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
|