Hi, I have a very interesting problem I have never seen before. Am am using a 16 MHz resonator and the timing on the chip is exactly 2 time slower than it should be. Is it possible this is due to an error in the chip data? This condition is true for all the chip family. Thanks, In advanced Ed.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sounds like something isn't quite right in the #config. These chips are a bit tricky to set up, I found some settings that work for me on the 18F4550 a few years ago and now just copy and paste them into any new programs! There are a few different multipliers and dividers in the oscillator.
Can you post the #chip and #config lines from your program?
I normally use this on an 18F4550 with a 20 MHz crystal, running the CPU at 48 MHz:
Have a look at the datasheet, figure 2-1, to see a block diagram of the system. PLLDIV=5 divides the 20 MHz from the crystal down to 4 MHz. This then goes into the PLL block, which produces 96 MHz. CPUDIV then causes this to be divided by 2, giving 48 MHz, and using FOSC=HSPLL_HS sends this through to the CPU.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hugh, Here is the #conig from the .asm file:
Program compiled by Great Cow BASIC (0.95 2015-12-27)
;Need help? See the GCBASIC forums at http://sourceforge.net/projects/gcbasic/forums,
;check the documentation or email w_cholmondeley at users dot sourceforge dot net.
;**************
;Set up the assembler options (Chip type, clock source, other bits and pieces)
LIST p=18F2455, r=DEC
Ed, those two lines I posted above are all that is needed to get the speed right when running an 18F4550 at 48 MHz from a 20 MHz crystal. To run the 18F2455 at 16 MHz from a 16 MHz resonator, try something like this:
Try that #chip line and one of the two #config lines, and see if either of them gets the chip running at the right speed. I haven't tried either of those configurations in hardware, but they both look like they should work from the datasheet.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hugh, The first config works ok but I still have to make the init rate of 19,200 to get 9600 baud rate. It is a little unstable in the first line of the LCD. Printing out "hello world" First line some times shows ello or Vell0. The second did not work at all!. It think I will try a different chip. Thanks, Ed.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, I have a very interesting problem I have never seen before. Am am using a 16 MHz resonator and the timing on the chip is exactly 2 time slower than it should be. Is it possible this is due to an error in the chip data? This condition is true for all the chip family. Thanks, In advanced Ed.
More info. Tried the hardware port with the same result. So now I am totally confused!! HELP!!!
Sounds like something isn't quite right in the #config. These chips are a bit tricky to set up, I found some settings that work for me on the 18F4550 a few years ago and now just copy and paste them into any new programs! There are a few different multipliers and dividers in the oscillator.
Can you post the #chip and #config lines from your program?
I normally use this on an 18F4550 with a 20 MHz crystal, running the CPU at 48 MHz:
Have a look at the datasheet, figure 2-1, to see a block diagram of the system. PLLDIV=5 divides the 20 MHz from the crystal down to 4 MHz. This then goes into the PLL block, which produces 96 MHz. CPUDIV then causes this to be divided by 2, giving 48 MHz, and using FOSC=HSPLL_HS sends this through to the CPU.
Hugh, Here is the #conig from the .asm file:
Program compiled by Great Cow BASIC (0.95 2015-12-27)
;Need help? See the GCBASIC forums at http://sourceforge.net/projects/gcbasic/forums,
;check the documentation or email w_cholmondeley at users dot sourceforge dot net.
;**************
;Set up the assembler options (Chip type, clock source, other bits and pieces)
LIST p=18F2455, r=DEC
include <p18f2455.inc></p18f2455.inc>
CONFIG LVP = OFF, MCLRE = OFF, WDT = OFF, FOSC = HS
Hugh, can you post your code for your config that worked for you. Thanks, Ed.
Ed, those two lines I posted above are all that is needed to get the speed right when running an 18F4550 at 48 MHz from a 20 MHz crystal. To run the 18F2455 at 16 MHz from a 16 MHz resonator, try something like this:
Another option might be to multiply and divide the frequency back:
Try that #chip line and one of the two #config lines, and see if either of them gets the chip running at the right speed. I haven't tried either of those configurations in hardware, but they both look like they should work from the datasheet.
Hugh, The first config works ok but I still have to make the init rate of 19,200 to get 9600 baud rate. It is a little unstable in the first line of the LCD. Printing out "hello world" First line some times shows ello or Vell0. The second did not work at all!. It think I will try a different chip. Thanks, Ed.