PIC16F684 + LCD to use the 256bytes of EEPROM - HELP


Closed Thread
Results 1 to 4 of 4

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Code:
    DEFINE OSC 8
    DEFINE LCD_DREG	PORTC
    DEFINE LCD_DBIT	0
    DEFINE LCD_RSREG	PORTA
    DEFINE LCD_RSBIT	4
    DEFINE LCD_EREG	PORTA
    DEFINE LCD_EBIT	5
    DEFINE LCD_BITS	4
    DEFINE LCD_LINES	2
    DEFINE LCD_COMMANDUS	2000
    DEFINE LCD_DATAUS	50
    max_mags var byte:max_medics var byte:rem_mags var byte:rem_medics var byte
    i var byte:mem_max_mags con 1:mem_max_medics con 2:mem_rem_mags con 3
    mem_rem_medics con 4:ammo var porta.0:medic var porta.1:backlight var portc.4
    signal var portc.5:blinkcount var byte:delaytemp var word:clear:osccon=$71
    cmcon0=7:ansel=0:option_reg=$7f:wpua=$13:intcon=$88:ioca=3:trisa=3:trisc=0
    porta=0:portc=0:max_mags=1:max_medics=2:rem_mags=3:rem_medics=4
    ON INTERRUPT GOTO mainroutine
    START:   flags=0:for blinkcount=1 to 5:signal=1:pause 500:signal=0:pause 500
    next blinkcount:backlight=1:lcdout $fe,1,"SUPPLIER",$fe,$c0,"MODULE"
    pause 3000:backlight=0:for blinkcount=1 to 5:signal=1:pause 500:signal=0
    pause 500:next blinkcount:gosub displayval:max_mags=0:max_medics=0:rem_mags=0
    rem_medics=0:gosub displayval
    DISABLE         'DISABLE ANY SOFTWARE INTERRUPTS
    intcon.7 = 0    'DISABLE INTERRUPTs IN HARDWARE
    write mem_max_mags,5:pause 25:write mem_max_medics,6:pause 25
    write mem_rem_mags,7:pause 25:write mem_rem_medics,8:pause 25
    intcon.7 = 1    'RE-ENABLE INTERRUPTs IN HARDWARE
    ENABLE           'RE-ENABLE PBP SOFTWARE INTERRUPTS
    read mem_max_mags,max_mags:read mem_max_medics,max_medics
    read mem_rem_mags,rem_mags:READ mem_rem_medics,rem_medics:GOSUB displayval
    loop1:  gosub blinksignalx5:goto loop1
    DISABLE
    mainroutine:
    donothing:
    RESUME
    ENABLE	
    displayval:     backlight=1:lcdout $fe,1,"maxmag",$fe,$c0,dec3 max_mags
    pause 2000:lcdout $fe,1:for i=0 to max_mags:signal=1:pause 300:signal=0
    pause 300:next i:lcdout $fe,1,"maxmed",$fe,$c0,dec3 max_medics:pause 2000
    for i=0 to max_medics:signal=1:pause 300:signal=0:pause 300:next i
    lcdout $fe,1,"remmag",$fe,$c0,dec3 rem_mags:pause 2000:for i=0 to rem_mags
    signal=1:pause 300:signal=0:pause 300:next i
    lcdout $fe,1,"remmed",$FE, $c0,DEC3 rem_medics:pause 2000
    for i=0 to rem_medics:signal=1:pause 300:signal=0:pause 300:next i:backlight=0
    return
    END
    Give that a shot and see if it works...
    Last edited by skimask; - 6th March 2008 at 15:39.

  2. #2
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Smile LCD+EEPROM problem solved

    Hi guys,

    Thanks for your help.
    Today, I read the docs for PICBASIC pro compiler and discovered that a # had to be added to display the ascii value. In fact I read this before but it never occured to me it could be important.
    I wrothe a #before the variable name and ... miracle, the value displayed right on my LCD, inf fact it was just displaying *some* value of the byte, not in ascii so I was seeing strange characters.

    I still have a technical question.
    I read that if used as Input pin, the pin 4 (RA3) had to be linked to VDD thoough a pull up resistor to prevent erratic behavior of the PIC. Is that right? What then should be the value of the resistor? 10K?

    As for now, no pull up is connected to the MCLR pin and everything works fine.

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by xnihilo View Post
    Thanks for your help.
    Today, I read the docs for PICBASIC pro compiler and discovered that a # had to be added to display the ascii value. In fact I read this before but it never occured to me it could be important.
    Which is what I did with DEC3.

    I still have a technical question.
    I read that if used as Input pin, the pin 4 (RA3) had to be linked to VDD thoough a pull up resistor to prevent erratic behavior of the PIC. Is that right? What then should be the value of the resistor? 10K?
    10K is fine.

Similar Threads

  1. Can't read sequential addresses in external EEPROM
    By tjkelly in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th February 2010, 15:46
  2. PIC16F684 + 8*2 LCD module
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 6th March 2008, 00:38
  3. Need help with LCD number display.
    By Steve Matson in forum mel PIC BASIC
    Replies: 8
    Last Post: - 27th June 2007, 00:07
  4. How to write/read strings EEPROM/LCD
    By g-hoot in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 11th February 2007, 07:26
  5. word variable to 25lc640
    By TONIGALEA in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 6th July 2004, 20:59

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