We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello!
I have created a GUI that can send data to any available serial port that it detects. Currently my GUI detects my lpc1114 however I do not fully understand what format I have to send data in to trigger my lpc1114 to respond. On the Lpc1114 itself I have a set of configs that I programmed and they work fine but I don't understand how to send the data via my GUI to trigger the lpc1114 to respond. Here's the code for the UART:
/* configure PINs GPIO1.6, GPIO1.7 for UART */ LPC_SYSCON->SYSAHBCLKCTRL |= ((1UL << 6) | /* enable clock for GPIO */ (1UL << 16) ); /* enable clock for IOCON */
LPC_IOCON->PIO1_6 = (1UL << 0); /* P1.6 is RxD */ LPC_IOCON->PIO1_7 = (1UL << 0); /* P1.7 is TxD */
/* configure UART0 */ LPC_SYSCON->SYSAHBCLKCTRL |= (1UL << 12); /* Enable clock to UART */ LPC_SYSCON->UARTCLKDIV = (4UL << 0); /* UART clock = CCLK / 4 */
LPC_UART->LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */ LPC_UART->DLL = 4; /* 115200 Baud Rate @ 12.0 MHZ PCLK */ LPC_UART->FDR = 0x85; /* FR 1.627, DIVADDVAL 5, MULVAL 8 */ LPC_UART->DLM = 0; /* High divisor latch = 0 */ LPC_UART->LCR = 0x03; /* DLAB = 0 */
LPC_UART->FCR |= (1UL << 0); /* Enable the UART Fifos */ LPC_UART->IER |= (1UL << 0); /* Enable the Receive Data interrupt */
NVIC_EnableIRQ(UART_IRQn); }
Just about any format will have your processor respond if you have correctly configured the UART.
Even wrong baudrate etc will quite often result in responses in form of overruns or garbled data bytes.
But you forgot to tag your code as code. And I didn't notice any interrupt service routine.
Anyway - what actual data to send is 100% up to you. You need to invent a meaningful protocol for how you want to send commands, requests or whatever you want to send. You might go for an ASCII protocol where you can simulate either your GUI or your microcontroller with a terminal software. Or you might go for a binary protocol with smaller messages, ability to use checksums etc. The sky is the limit - that's the great part about being an R&D engineer: you get the chance to engineer things.