Hello,
I have a little problem with a LCD display.
Just when I use an interrupt from timer 1, then my LCD-display is not working, but contains a row of 'blocks' on row 1. Can it be that the init of the display (lcdinit) will not work if during the init an interrupt appears? The program in the loop works fine.
If I remove the complete parameter code for timer 1, then the LCD works fine.
See below the program code with the interupt and a sample program.
**********************************************************************************
'PIC 16F628A, with 2x16 LCD and 20Mhz crystal
Define CONF_WORD = 0x3f42
AllDigital
TRISB = 0x00 'port b as output
TRISA = 0x07 'first three bits as output
Define CLOCK_FREQUENCY = 20
Define LCD_LINES = 2
Define LCD_CHARS = 16
Define LCD_BITS = 4 'allowed values are 4 and 8 - the number of data interface lines
Define LCD_DREG = PORTB
Define LCD_DBIT = 4 '0 or 4 for 4-bit interface, ignored for 8-bit interface
Define LCD_RSREG = PORTA
Define LCD_RSBIT = 4
Define LCD_EREG = PORTA
Define LCD_EBIT = 3
Define LCD_RWREG = 0 'set to 0 if not used, 0 is default
Define LCD_RWBIT = 0 'set to 0 if not used, 0 is default
Define LCD_COMMANDUS = 5000 'delay after LCDCMDOUT, default value is 5000
Define LCD_DATAUS = 100 'delay after LCDOUT, default value is 100
Define LCD_INITMS = 100 'delay used by LCDINIT, default value is 100
'configure Timer 1
T1CON = 0x30 'prescaler
T1CON.T1OSCEN = 1 'oscilator enabled
T1CON.TMR1CS = 0 'synchronise with oscilator
T1CON.TMR1ON = 1 'enable timer 1
TMR1H = 0x0b 'high byte of countvalue
TMR1L = 0xdc 'low byte of countvalue
INTCON.GIE = 1
INTCON.PEIE = 1
PIE1.TMR1IE = 1
PIR1.TMR1IF = 0
Dim intrcnt As Byte
'ínitialisatie
Lcdinit 0
loop:
'just a simple code for running test
If PORTB.1 = 0 Then
PORTB.1 = 1
Else
PORTB.1 = 0
Endif
WaitMs 1000
Lcdcmdout LcdClear 'clear LCD display
Lcdout "test display"
WaitMs 100
Goto loop
End
______________________________________
On Interrupt 'every 0,1 second
Save System
PIR1.TMR1IF = 0
intrcnt = intrcnt + 1
If intrcnt = 5 Then '= 0.5 second
intrcnt = 0
'just a simple code for running test
If PORTB.0 = 0 Then
PORTB.0 = 1
Else
PORTB.0 = 0
Endif
Endif
TMR1H = 0x0b 'load new values to counter
TMR1L = 0xdc 'load new values to counter
Resume
I have a little problem with a LCD display.
Just when I use an interrupt from timer 1, then my LCD-display is not working, but contains a row of 'blocks' on row 1. Can it be that the init of the display (lcdinit) will not work if during the init an interrupt appears? The program in the loop works fine.
If I remove the complete parameter code for timer 1, then the LCD works fine.
See below the program code with the interupt and a sample program.
**********************************************************************************
'PIC 16F628A, with 2x16 LCD and 20Mhz crystal
Define CONF_WORD = 0x3f42
AllDigital
TRISB = 0x00 'port b as output
TRISA = 0x07 'first three bits as output
Define CLOCK_FREQUENCY = 20
Define LCD_LINES = 2
Define LCD_CHARS = 16
Define LCD_BITS = 4 'allowed values are 4 and 8 - the number of data interface lines
Define LCD_DREG = PORTB
Define LCD_DBIT = 4 '0 or 4 for 4-bit interface, ignored for 8-bit interface
Define LCD_RSREG = PORTA
Define LCD_RSBIT = 4
Define LCD_EREG = PORTA
Define LCD_EBIT = 3
Define LCD_RWREG = 0 'set to 0 if not used, 0 is default
Define LCD_RWBIT = 0 'set to 0 if not used, 0 is default
Define LCD_COMMANDUS = 5000 'delay after LCDCMDOUT, default value is 5000
Define LCD_DATAUS = 100 'delay after LCDOUT, default value is 100
Define LCD_INITMS = 100 'delay used by LCDINIT, default value is 100
'configure Timer 1
T1CON = 0x30 'prescaler
T1CON.T1OSCEN = 1 'oscilator enabled
T1CON.TMR1CS = 0 'synchronise with oscilator
T1CON.TMR1ON = 1 'enable timer 1
TMR1H = 0x0b 'high byte of countvalue
TMR1L = 0xdc 'low byte of countvalue
INTCON.GIE = 1
INTCON.PEIE = 1
PIE1.TMR1IE = 1
PIR1.TMR1IF = 0
Dim intrcnt As Byte
'ínitialisatie
Lcdinit 0
loop:
'just a simple code for running test
If PORTB.1 = 0 Then
PORTB.1 = 1
Else
PORTB.1 = 0
Endif
WaitMs 1000
Lcdcmdout LcdClear 'clear LCD display
Lcdout "test display"
WaitMs 100
Goto loop
End
______________________________________
On Interrupt 'every 0,1 second
Save System
PIR1.TMR1IF = 0
intrcnt = intrcnt + 1
If intrcnt = 5 Then '= 0.5 second
intrcnt = 0
'just a simple code for running test
If PORTB.0 = 0 Then
PORTB.0 = 1
Else
PORTB.0 = 0
Endif
Endif
TMR1H = 0x0b 'load new values to counter
TMR1L = 0xdc 'load new values to counter
Resume
Last edited: