![]() |
![]() |
![]() |
|
|
|||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) |
|
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??? |
|
|
|
|
|
|
(permalink) |
|
Unlike bit-banged serial I/O where you can easily code for inverted or non-inverted I/O, the serial peripheral in the 18F452 is inverted.
If you need non-inverted signals on the LCD you'll need to add invertors to the '452. Good luck. Mike Last edited by Mike, K8LH; 13th July 2006 at 01:39 PM. |
|
|
|
|
|
|
(permalink) |
|
It's also usual to check the UART is empty before you transfer data to it, although presumably you're adding the pause to ensure that?.
Check my RS232 PIC tutorial for how to send data using the UART, I suggest using a subroutine as my tutorial does. As Mike suggests, does your display require inverted or normal RS232?, the hardware USARTS are designed to feed an inverting MAX232. |
|
|
|
|
|
|
(permalink) |
|
My LCD requires inverted signals (why cant a standard be standard?? sigh...). The MAX232 was the answer I was looking for. Wanted to make sure I wasnt missing something. Thanks guys!
|
|
|
|
|
|
|
(permalink) | |
|
Quote:
|
||
|
|
|
|
|
(permalink) | |
|
Quote:
|
||
|
|
|