18F1220 LCD and Sleep


Closed Thread
Results 1 to 5 of 5
  1. #1

    Default 18F1220 LCD and Sleep

    The program below is supposed to display "BEFORE SLEEP" on the LCD on power-up, then power-down the LCD and go to sleep. Upon external interrupt, the LCD is supposed to display "AWAKE AGAIN!", the LED comes on, and return to Main. With the "LOW PORTA.6" line commented out, the LCD displays both messages as it should. With the line in the program, the LCD goes blank as it should, but it only displays a single row of blocks during the "Awake" routine. The LED behaves as it should. What could be the problem?

    TRISA = %00100000 ;RA5 input, all else outputs
    TRISB = %10000111 ;RB0,1,2,&7 inputs
    WDTCON = 0 ;WDT off
    ADCON0 = %00000000 ;ADC off
    ADCON1 = %01111111 ;All pins digital
    LVDCON = %00000000 ;LVD off
    CCP1CON = %00000000 ;CCP/PWM off
    OSCCON = %01100000 ;RUN mode,4MHZ,INT OSC
    RCON = %00000000 ;Prioritys off
    EECON1 = %00000100 ;Access flash
    INTCON2 = %11000000 ;Disable PORTB pullups,INT0 rising edge
    INTCON3 = %00000000 ;INT1 enabled
    PIE1 = %00000000 ;Disable A/D,EUSART,CCP,TMR2,TMR1 overflow ints
    PIE2 = %00000000 ;Disable OSC Fail,EEPROM,LVD,TMR3 overflow ints
    IPR1 = %00000000 ;A/D,EUSART,CCP,TMR2,TMR1 low priority
    IPR2 = %00000000 ;OSC Fail,EEPROM,LVD,TMR3 ints low priority
    RCON = %00000000 ;Disable priority levels
    T0CON = %00000000 ;TMR0 off
    T1CON = %00000000 ;TMR1 off
    T2CON = %00000000 ;TMR2 off
    T3CON = %00000000 ;TMR3 off
    TXSTA = %00000000 ;Transmit disabled
    RCSTA = %00000000 ;Receive disabled

    @ __CONFIG _CONFIG1H, _IESO_OFF_1H & _FSCM_OFF_1H & _INTIO2_OSC_1H
    @ __CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L & _BORV_27_2L
    @ __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_32K_2H
    @ __CONFIG _CONFIG3H, _MCLRE_OFF_3H
    @ __CONFIG _CONFIG4L, _DEBUG_OFF_4L & _LVP_OFF_4L & _STVR_OFF_4L
    @ __CONFIG _CONFIG5L, _CP0_OFF_5L & _CP1_OFF_5L
    @ __CONFIG _CONFIG5H, _CPB_OFF_5H & _CPD_OFF_5H
    @ __CONFIG _CONFIG6L, _WRT0_OFF_6L & _WRT1_OFF_6L
    @ __CONFIG _CONFIG6H, _WRTC_OFF_6H & _WRTB_OFF_6H & _WRTD_OFF_6H
    @ __CONFIG _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L
    @ __CONFIG _CONFIG7H, _EBTRB_OFF_7H

    DEFINE LCD_DREG PORTA
    DEFINE LCD_DBIT 0
    DEFINE LCD_RSREG PORTA
    DEFINE LCD_RSBIT 4
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 5
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2
    DEFINE LCD_COMMANDUS 2000
    DEFINE LCD_DATAUS 50

    INCLUDE "DT_INTS-18.bas" ; Base Interrupt System
    INCLUDE "ReEnterPBP-18.bas" ; Include if using PBP interrupts

    ASM
    INT_LIST macro ; IntSource, Label, Type, ResetFlag?
    INT_Handler INT_INT, _Awake, PBP, yes
    endm
    INT_CREATE ; Creates the interrupt processor
    ENDASM

    @ INT_ENABLE INT_INT ; enable external (INT) interrupts

    Main:
    HIGH PORTA.6 'LCD Power ON
    PAUSE 1000
    LCDOUT $fe,1,"BEFORE"
    LCDOUT $fe,$C0,"SLEEP"
    PAUSE 1000
    'LOW PORTA.6 'LCD Power OFF
    @ SLEEP
    @ NOP

    GOTO Main

    '---[INT - interrupt handler]---------------------------------------------------
    Awake:

    HIGH PORTB.4 'LED ON
    HIGH PORTA.6 'LCD Power ON
    LCDOUT $fe,1,"AWAKE"
    LCDOUT $fe,$C0,"AGAIN!"
    PAUSE 100
    LOW PORTB.4 'LED OFF

    @ INT_RETURN

    Thank you for any help.

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default

    You've missed the pause 1000 after turning on the LCD power in your interrupt service. You need to give time to the LCD to initialize. Is that the cause?

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Thanks for trying, Jerson. The pause just causes the blocks to be displayed longer.

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Wink Reuteu ....

    Hi, JDerson

    See Manual $ 5.39 ...

    "FLAGS" to clear before entering sleep ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5


    Did you find this post helpful? Yes | No

    Default

    FLAGS = 0 solved the problem. Thank you for your help.

Similar Threads

  1. Need help with SLEEP mode
    By aggie007 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 28th November 2007, 09:56
  2. Replies: 3
    Last Post: - 27th November 2007, 08:56
  3. Switch LCD OFF during sleep, possible?
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 16th December 2006, 11:39
  4. LCD Clock, Interrup
    By Patrick in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 16th July 2006, 16:00
  5. Wierd sleep issue
    By orca in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 14th March 2006, 22:06

Members who have read this thread : 1

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