Trying to use LCD with UART in DMX Mode
I am experimenting with an 18F45K42 using the UART DMX mode on a Curiosity HPC board. I have a standard 2x16 LCD connected.
Currently I have UART1 set at 250000 baud as required for DMX. The internal oscillator HFINTOSC is set at 64MHz. The clock divider is set at 1. With these settings the LCD does not display anything in response to commands or input.
If I lower the internal oscillator frequency, the LCD does receive commands and display properly. It works with the oscillator set as high as 16MHz.
The problem is that any oscillator setting less than 64MHz breaks the DMX functionality. I can see on my scope that a DMX signal is still being transmitted, but the DMX lighting fixture I am using to test does not respond to it. It looks like this is because the timing of the signal is altered.
I'd like to have the LCD and the DMX work at the same time. I presume I have three possible fixes:
1) Change the value of U1BRG in the UART setup to produce the 250000 baud rate at 16MHz,
2) Alter the LCD code to work at the higher frequency,
3) Some combination of 1 & 2.
I am new to PIC micro controllers and at my present level of understanding, I'm not sure I can even ask the questions needed to attack this issue. Can someone kindly point me in the right direction?
This is how the UART is initialized:
//UART module settings
U1CON0bits.MODE = 0b1010; //Select DMX mode
U1CON0bits.TXEN = 1; //Enable transmitter
U1CON0bits.RXEN = 0; //Disable receiver
U1CON2bits.TXPOL = 0; //Standard polarity, TX pin will idle high
U1CON2bits.STP = 0b10; //2 stop bits
//DMX data packet settings
U1P1 = 512-1; //Total number of data bytes - 1
U1P2 = 0x00; //Not used in DMX controller
U1P3 = 0x00; //Not used in DMX controller
// Baud rate generator settings
U1CON0bits.U1BRGS = 1; //High speed baud generation
U1BRG = 0x3F; //Value for U1BRG for Fosc = 64MHz
U1ERRIEbits.TXMTIE = 1;
//PPS settings for TX functionality on pin RC6
ANSELCbits.ANSELC6 = 0; //Make RC6 a digital I/O
TRISCbits.TRISC6 = 0; //Make RC6 an output
RC6PPS = 0b010011; //Assign TX functionality to RC6
U1ON = 0x01; //Turn on UART module