16F872 and LCD


Closed Thread
Results 1 to 40 of 49

Thread: 16F872 and LCD

Hybrid View

  1. #1
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Default

    I use PBP v2.45 and have not modified anything.

    The PIC runs on OSC 20


    Edit: Just tryed to put in a 4 Mhz crystal but i does´t work
    Last edited by Fredrick; - 17th January 2008 at 17:43.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Fredrick View Post
    I use PBP v2.45 and have not modified anything.
    The PIC runs on OSC 20
    Edit: Just tryed to put in a 4 Mhz crystal but i does´t work
    Apparently, the bug mentioned at the end of post #9 is only applicable to PBP2.50(a).

    But still, something wierd going on...

    Change your LCD_DATAUS from 600 to 255.
    LCD_DATAUS is a byte value (up until PBP2.50 as far as I know), so 600 is actually 88 (600 - 256 - 256 ) as far as PBP knows.

    Past that...
    Check the pullup on MCLR?
    Watchdog timer off?

  3. #3
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Default

    I dont know what i have done but now the display shows "333333333333333" on both lines and some times the temerature shows on diffrent positions in the display whit "3" all over the display.

    The display is an HD44780 OLED, can the display be broken?

    The PBP Hello World sampel works..

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Fredrick View Post
    I dont know what i have done but now the display shows "333333333333333" on both lines and some times the temerature shows on diffrent positions in the display whit "3" all over the display.
    The display is an HD44780 OLED, can the display be broken?
    The PBP Hello World sampel works..
    I'm sure the 'Hello World' sample works just fine, but when you start messing around with some of the special LCD commands and stuff, the LCD timing starts to matter.
    Did you change the LCD_DATAUS yet?

  5. #5
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Default

    Yes i have.

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Give this a shot:

    Code:
    @ DEVICE PIC16F872, HS_OSC, WDT_OFF, PWRT_ON, LVP_OFF, PROTECT_OFF
    DEFINE OSC 20
    DEFINE LCD_COMMANDUS 3000
    DEFINE LCD_DATAUS 250
    temperature var word : count_remain var byte : count_per_c var byte
    dq var portb.2 : ADCON1 = 7 : pause 1000 : lcdout $fe , 1
    mainloop: OWOut DQ , 1 , [ $CC , $44 ]
    waitloop: OWIn DQ, 4, [count_remain]	 : If count_remain = 0 Then waitloop
    owout dq, 1, [$cc,$be]
    owin dq , 0 , [ temperature.lowbyte , temperature.highbyte , skip 4 , count_remain , count_per_c ]
    temperature = ( ( ( temperature >> 1 ) * 100 ) - 25 ) + ( ( ( count_per_c - count_remain ) * 100 ) / count_per_c )
    Lcdout $fe , $80 , DEC3 ( temperature / 100 ) , "." , DEC2 temperature, " C"
    temperature = ( temperature * / 461 ) + 3200
    Lcdout $fe , $c0 , DEC3 ( temperature / 100 ) , "." , DEC2 temperature , " F"
    Pause 1000 : goto mainloop

    Also, in your original code, you show:
    define OSC 20

    Put all DEFINE's in upper case. It's a bit weird like that.
    Your original code was probably still compiled as if it were for a 4 Mhz oscillator, even though you had 'define OSC 20'.
    Last edited by skimask; - 17th January 2008 at 18:47.

  7. #7
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Place this in the first section of your code;

    @ device pic16F872, hs_osc, wdt_off, pwrt_on, lvp_off, protect_off

    Change DEFINE LCD_DATAUS 600 to DEFINE LCD_DATAUS 50.

    Does it work now?
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  8. #8
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Default

    No i does not work...

  9. #9
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Default

    temperature = ( temperature * / 461 ) + 3200

    ERROR Line 23: Bad expression. (TEST.pbp)


    I use Microcode Studio and microcode put define in uppercase by auto, or do i still have to write it in uppercase?

  10. #10
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Fredrick View Post
    temperature = ( temperature * / 461 ) + 3200

    ERROR Line 23: Bad expression. (TEST.pbp)


    I use Microcode Studio and microcode put define in uppercase by auto, or do i still have to write it in uppercase?
    I just write it in uppercase myself.
    No questions about it then.
    As far as the bad expression, the fix is in the manual.

  11. #11
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Default

    Bad expression is fixed now, but the problem whit the LCD still remains...

    This is driving me crasy..... gaaahhh i have to take a pause and a cup of coffee now...

  12. #12
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Fredrick View Post
    I use PBP v2.45 and have not modified anything.
    Sounds like it's time to get the 2.50a update...

  13. #13
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Default

    Why? 2.45 should work...

    And update the PBP is not an garanti for that i will work..

  14. #14
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Fredrick View Post
    Why? 2.45 should work...

    And update the PBP is not an garanti for that i will work..
    The update is only $25, get a new book, all the fixes, support for 32 bit variables, etc.

  15. #15
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Default

    Maybe i will do that, but still i want to get the LCD to work now..... with the current version...

  16. #16
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Fredrick View Post
    Maybe i will do that, but still i want to get the LCD to work now..... with the current version...
    Are you using the PBP DEMO version?

  17. #17
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Default

    No i use PICBASIC PRO

    Will it do any diffrent if i use an PIC16F876 insted?
    Last edited by Fredrick; - 17th January 2008 at 19:28.

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