the dude of dudes
New Member
I'm attempting to use my Matrix Orbital LCD display with a PIC 18452 USART. The default setting on the LCD is 2400 baud, heres my code:
ORG 0
goto Main
ORG 0x20
Main
call SerialEnable
PrintTest
movlw 'T'
movwf TXREG, A
call Pause
movlw 'E'
movwf TXREG, A
call Pause
movlw 'S'
movwf TXREG, A
call Pause
movlw 'T'
movwf TXREG, A
call Pause
goto PrintTest
;---------------------------------------------------
SerialEnable
;--- enable USART ---
bsf RCSTA, SPEN, A ;enable Serial Port
bcf TRISC, 6, A ;make TX line output
bsf TRISC, 7, A ;make RX line input
;--- enable Asynchronous mode ---
movlw .129 ;2400 baud parameter
movwf SPBRG, A ;load baud rate into generator
bcf TXSTA, BRGH, A ;disable high speed baud rate
bcf TXSTA, SYNC, A ;asynchronous mode
bcf TXSTA, TX9, A ;select 8 bit transmission
bsf TXSTA, TXEN, A ;enable transmission
return
;---------------------------------------------------
Pause clrf 0x01, ACCESS ;clear timers
clrf 0x02, ACCESS
movlw 0x10
movwf 0x03, A
Countdown
decfsz 0x01, F, ACCESS
goto Countdown
decfsz 0x02, F, ACCESS
goto Countdown
decfsz 0x03, F, ACCESS
goto Countdown
return
Keep in mind, this is only test code. I realize I can do a bit test to determine when TXREG is empty. I used a long pause between chars to rule out buffer overrun. My problem is Im not getting TEST on the display. I get the same 4 garbage chars over and over instead. Comparing their ASCII codes, it seems to me that the USART isnt inverting the transmitted bits. I've used bit-banging code on a PIC 16F84A to run this display, and I know it works. I also know it requires the data bits to be inverted, same with the START and STOP bits. I cant test my theory since I cant find a way to invert the START/STOP bits on the PIC18452. I feel like I'm missing something obvious, anyone have any ideas???
ORG 0
goto Main
ORG 0x20
Main
call SerialEnable
PrintTest
movlw 'T'
movwf TXREG, A
call Pause
movlw 'E'
movwf TXREG, A
call Pause
movlw 'S'
movwf TXREG, A
call Pause
movlw 'T'
movwf TXREG, A
call Pause
goto PrintTest
;---------------------------------------------------
SerialEnable
;--- enable USART ---
bsf RCSTA, SPEN, A ;enable Serial Port
bcf TRISC, 6, A ;make TX line output
bsf TRISC, 7, A ;make RX line input
;--- enable Asynchronous mode ---
movlw .129 ;2400 baud parameter
movwf SPBRG, A ;load baud rate into generator
bcf TXSTA, BRGH, A ;disable high speed baud rate
bcf TXSTA, SYNC, A ;asynchronous mode
bcf TXSTA, TX9, A ;select 8 bit transmission
bsf TXSTA, TXEN, A ;enable transmission
return
;---------------------------------------------------
Pause clrf 0x01, ACCESS ;clear timers
clrf 0x02, ACCESS
movlw 0x10
movwf 0x03, A
Countdown
decfsz 0x01, F, ACCESS
goto Countdown
decfsz 0x02, F, ACCESS
goto Countdown
decfsz 0x03, F, ACCESS
goto Countdown
return
Keep in mind, this is only test code. I realize I can do a bit test to determine when TXREG is empty. I used a long pause between chars to rule out buffer overrun. My problem is Im not getting TEST on the display. I get the same 4 garbage chars over and over instead. Comparing their ASCII codes, it seems to me that the USART isnt inverting the transmitted bits. I've used bit-banging code on a PIC 16F84A to run this display, and I know it works. I also know it requires the data bits to be inverted, same with the START and STOP bits. I cant test my theory since I cant find a way to invert the START/STOP bits on the PIC18452. I feel like I'm missing something obvious, anyone have any ideas???