PDA

View Full Version : 10mhz yes, 20mhz no...



dragons_fire
- 28th March 2007, 17:06
i have tried to use both a 16f628 and a 16f877a to output to a matrix orbital serial lcd. with a 10mhz crystal, everything works fine. the code with the 10 mhz crystal is:

@ DEVICE HS_OSC
DEFINE OSC 10
cmcon = 7

'variables
'----------------------------------------------------------

baudLCD CON 32 'baud rate for lcd
lcd VAR PORTA.3 'lcd port

'Startup Program
'--------------------------------------------------------------------------------------

high PORTD.0
Pause 3000
Low PORTD.0
SerOut2 lcd, baudlcd,[254,"X"] 'clear screen
Pause 100
SerOut2 lcd, baudlcd,[254,"X"] 'clear screen again
SerOut2 lcd, baudlcd,[254,"P",140] 'change resolution
Pause 100

'main program
'----------------------------------------------------------

start:
SerOut2 lcd, baudlcd,[254,"G",1,1,"HELLO"]
pause 500
goto start
end

when i change it out to 20mhz crystal, i shouldnt have to change the bausd rate or anything, just the "define osc 20"
right? both chips im using, are the -20 versions, and the datasheet says they will do 20.
thanks for any help...

skimask
- 28th March 2007, 17:20
i have tried to use both a 16f628 and a 16f877a to output to a matrix orbital serial lcd. with a 10mhz crystal, everything works fine. the code with the 10 mhz crystal is:

@ DEVICE HS_OSC
DEFINE OSC 10
cmcon = 7

'variables
'----------------------------------------------------------

baudLCD CON 32 'baud rate for lcd
lcd VAR PORTA.3 'lcd port

'Startup Program
'--------------------------------------------------------------------------------------

high PORTD.0
Pause 3000
Low PORTD.0
SerOut2 lcd, baudlcd,[254,"X"] 'clear screen
Pause 100
SerOut2 lcd, baudlcd,[254,"X"] 'clear screen again
SerOut2 lcd, baudlcd,[254,"P",140] 'change resolution
Pause 100

'main program
'----------------------------------------------------------

start:
SerOut2 lcd, baudlcd,[254,"G",1,1,"HELLO"]
pause 500
goto start
end

when i change it out to 20mhz crystal, i shouldnt have to change the bausd rate or anything, just the "define osc 20"
right? both chips im using, are the -20 versions, and the datasheet says they will do 20.
thanks for any help...

Probably need to add a bit more delay for the LCD, command_us and data_us. Add those defines and increase them until it works (note:data_us is a byte value, only goes to 255, command_us is a word value).
Maybe a bit of character pacing on the serial port? Try a bit of a delay there also.
For further reference, it's all in the little green manual...

dragons_fire
- 28th March 2007, 19:29
shouldnt the delay for the lcd not matter?? since it works fine at 10mhz, is should be the same at 20, shouldnt it???

can someone please elaborate on the command_us and data_us? i have never used these before, and i looked through the book a bit, and couldnt find anything. i also searched on here, and couldnt find enough info on it..

aerostar
- 28th March 2007, 20:35
If you are not using the latest PBP then this might be the cause. Some years ago I had the same problem, and by adding in some extra NOPS in the LCD routine in the PBP library I got it to work. I cannot remember what version it was probably 2.42 or earlier, and I think it was also specific to the display I was using at the time, cannot remember the make.

skimask
- 28th March 2007, 22:32
shouldnt the delay for the lcd not matter?? since it works fine at 10mhz, is should be the same at 20, shouldnt it???

can someone please elaborate on the command_us and data_us? i have never used these before, and i looked through the book a bit, and couldnt find anything. i also searched on here, and couldnt find enough info on it..

I used the wrong syntax.
It's lcd_commandus and lcd_dataus. It's in the green manual.

paul borgmeier
- 29th March 2007, 00:40
The LCD commands just noted won't help because he is using a serial lcd with serout2, not the LCDOUT command. I don't have an answer, just hoping to save him time debugging.

skimask
- 29th March 2007, 01:34
The LCD commands just noted won't help because he is using a serial lcd with serout2, not the LCDOUT command. I don't have an answer, just hoping to save him time debugging.

Hey...good point...DOH!

You running 20mhz and SEROUT2 with a baud of 32. I'm thinking maybe the difference between say 31, 32, and 33, might be the ticket. Maybe your baud rate is off as a result of your crystal being off a bit.
Try 31 and 33 and see what happens.

Does the LED on D.0 respond properly? What does the LCD do? Do you have the Power-Up-Timeout enabled?

dragons_fire
- 29th March 2007, 02:11
i think the led works fine, it seems too, i havent actually timed it to make sure its correct. the lcd is a serial lcd, and it just shows wierd characters. the same as if i cahnge the baud rate. i was thinking it might have something to do with my crystal being off, but i have tried a couple, with a couple different chips. i will try playing around with the timing and baud rate and see what i can come up with.

skimask
- 29th March 2007, 02:15
i think the led works fine, it seems too, i havent actually timed it to make sure its correct. the lcd is a serial lcd, and it just shows wierd characters. the same as if i cahnge the baud rate. i was thinking it might have something to do with my crystal being off, but i have tried a couple, with a couple different chips. i will try playing around with the timing and baud rate and see what i can come up with.

That's what I'm thinking. You've got 32 set in for 19,200. Maybe set the jumpers for the lowest possible baud rate and work your way up and see if/where it fails.

paul borgmeier
- 29th March 2007, 04:04
You also might want to try and see if you can communicate with hyperterminal (to make sure your pic is set just right)

paul borgmeier
- 29th March 2007, 04:09
I used the wrong syntax.
It's lcd_commandus and lcd_dataus. It's in the green manual.

thinking along these lines ... there is an optional "pace" setting you can make to slow down the presentation of bytes from serout2. You might want to play with that as well. The "pace" setting also is in the green manual(under serout2)

skimask
- 29th March 2007, 04:20
I wonder if maybe the 20mhz crystal is oscillating at 20mhz...might be drawn off on a harmonic or something along those lines. I know I've had a bit of a rough time with crystals once I get above about 10mhz, especially on the solder-less-breadboards. Usually nothing that a cap value change couldn't fix (i.e. 15pf -> 33pf or the other way), but once in awhile, I'd just get a crystal that wouldn't work in the application. Swap it out with another one, works great...etc...
Just more stuff for you to look at I suppose...