10mhz yes, 20mhz no...


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Apr 2006
    Location
    Alberta Canada
    Posts
    166

    Default 10mhz yes, 20mhz no...

    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...

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by dragons_fire View Post
    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...

  3. #3
    Join Date
    Apr 2006
    Location
    Alberta Canada
    Posts
    166


    Did you find this post helpful? Yes | No

    Default

    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..

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by dragons_fire View Post
    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.

  5. #5
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    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.
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by paul borgmeier View Post
    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?

  7. #7
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    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)
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  8. #8
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    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...

  9. #9


    Did you find this post helpful? Yes | No

    Default

    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.

  10. #10
    Join Date
    Apr 2006
    Location
    Alberta Canada
    Posts
    166


    Did you find this post helpful? Yes | No

    Default

    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.

  11. #11
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by dragons_fire View Post
    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.

  12. #12
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    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
    Salt Lake City, UT
    USA
    __________________

Similar Threads

  1. 16F877A with 20MHz XTAL not working?
    By ustredna in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 19th August 2011, 15:04
  2. Replies: 0
    Last Post: - 5th September 2007, 12:25
  3. 20MHz improve RF over 16F628A?
    By mbw123 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 28th November 2006, 16:04
  4. 18F458 and 20MHz osc problem...
    By batee in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 16th October 2004, 20:16
  5. 16F877 20MHz problem
    By swordman in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 31st July 2004, 10:02

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts