Hi,
I am a beginner in this field. Right now, I am using 2 boards, including Diablo 16 LCD from 4dsystem and Leopard Gecko from EFM. My goal is to create a communication between 2 boards through Serial connection (UART).
Here is my code, right now, I can send the command from Host (Leopard Gecko) to write the object (Led diggit) on Diablo 16 board.
So, my situation is that I want to receive back the update ( or report ) from Diablo 16 to Host. But, I do not know how to receive, because I cannot get the rhythm.
int main(void)
{
/* Chip errata */
CHIP_Init();
unsigned int i= 1;
unsigned int checksum, msb, lsb;
struct objectReport report;
USART_TypeDef *uart = UART1;
CMU_HFRCOBandSet(cmuHFRCOBand_28MHz);
SystemCoreClockUpdate();
CMU_ClockEnable(cmuClock_HFPER, true);
CMU_ClockEnable(cmuClock_GPIO, true);
CMU_ClockEnable(cmuClock_UART1, true);
/* Initialize USART */
USART_InitAsync_TypeDef init = {
usartDisable, /* Disable RX/TX when init completed. */
0, /* Use current configured reference clock for configuring baudrate. */
9600, /* 57600 bits/s. */
usartOVS16, /* 16x oversampling. */
usartDatabits8, /* 8 databits. */
usartNoParity, /* No parity. */
usartStopbits1, /* 1 stopbit. */
false, /* Do not disable majority vote. */
false, /* Not USART PRS input mode. */
usartPrsRxCh0 /* PRS channel 0. */
};
/* To avoid false start, configure output as high */
GPIO_PinModeSet(gpioPortB, 9, gpioModePushPull, 1);
/* Define input, no filtering */
GPIO_PinModeSet(gpioPortB, 10, gpioModeInput, 0);
/* Configure USART for basic async operation */
USART_InitAsync(uart, &init);
/* Enable pins at default location */
uart->ROUTE = USART_ROUTE_LOCATION_LOC2 | UART_ROUTE_RXPEN | UART_ROUTE_TXPEN;
/* Clear previous RX interrupts */
USART_IntClear(UART1, UART_IF_RXDATAV);
NVIC_ClearPendingIRQ(UART1_RX_IRQn);
/* Finally enable it */
USART_Enable(uart, usartEnable);
/* If first word of user data page is non-zero, enable eA Profiler trace */
BSP_TraceProfilerSetup();
/* Setup SysTick Timer for 1 msec interrupts */
if (SysTick_Config(CMU_ClockFreqGet(cmuClock_CORE) / 1000)) while (1) ;
/* Enable LCD without voltage boost */
SegmentLCD_Init(false);
while (1)
{
SegmentLCD_Number(i);
Delay(1000);
lsb = (i >> 0) & 0xFF ;
msb = (i >> 8) & 0xFF ;
USART_Tx(uart,GENIE_WRITE_OBJ);
checksum = GENIE_WRITE_OBJ;
USART_Tx(uart,GENIE_OBJ_LED_DIGITS);
checksum ^= GENIE_OBJ_LED_DIGITS;
USART_Tx(uart,0);
checksum ^=0;
USART_Tx(uart,msb);
checksum ^=msb;
USART_Tx(uart,lsb);
checksum ^=lsb;
USART_Tx(uart,checksum);
++i;
}
Above is my code for sending command from Host to LCD. I did the same thing in reserve to receive the report back from LCD to Host but I failed.
Please guide me. Thank you
Hi, I am a beginner in this field. Right now, I am using 2 boards, including Diablo 16 LCD from 4dsystem and Leopard Gecko from EFM. My goal is to create a communication between 2 boards through Serial connection (UART).
Here is my code, right now, I can send the command from Host (Leopard Gecko) to write the object (Led diggit) on Diablo 16 board. So, my situation is that I want to receive back the update ( or report ) from Diablo 16 to Host. But, I do not know how to receive, because I cannot get the rhythm.
int main(void) { /* Chip errata */ CHIP_Init(); unsigned int i= 1; unsigned int checksum, msb, lsb; struct objectReport report; USART_TypeDef *uart = UART1; CMU_HFRCOBandSet(cmuHFRCOBand_28MHz); SystemCoreClockUpdate(); CMU_ClockEnable(cmuClock_HFPER, true); CMU_ClockEnable(cmuClock_GPIO, true); CMU_ClockEnable(cmuClock_UART1, true); /* Initialize USART */ USART_InitAsync_TypeDef init = { usartDisable, /* Disable RX/TX when init completed. */ 0, /* Use current configured reference clock for configuring baudrate. */ 9600, /* 57600 bits/s. */ usartOVS16, /* 16x oversampling. */ usartDatabits8, /* 8 databits. */ usartNoParity, /* No parity. */ usartStopbits1, /* 1 stopbit. */ false, /* Do not disable majority vote. */ false, /* Not USART PRS input mode. */ usartPrsRxCh0 /* PRS channel 0. */ }; /* To avoid false start, configure output as high */ GPIO_PinModeSet(gpioPortB, 9, gpioModePushPull, 1); /* Define input, no filtering */ GPIO_PinModeSet(gpioPortB, 10, gpioModeInput, 0); /* Configure USART for basic async operation */ USART_InitAsync(uart, &init); /* Enable pins at default location */ uart->ROUTE = USART_ROUTE_LOCATION_LOC2 | UART_ROUTE_RXPEN | UART_ROUTE_TXPEN; /* Clear previous RX interrupts */ USART_IntClear(UART1, UART_IF_RXDATAV); NVIC_ClearPendingIRQ(UART1_RX_IRQn); /* Finally enable it */ USART_Enable(uart, usartEnable); /* If first word of user data page is non-zero, enable eA Profiler trace */ BSP_TraceProfilerSetup(); /* Setup SysTick Timer for 1 msec interrupts */ if (SysTick_Config(CMU_ClockFreqGet(cmuClock_CORE) / 1000)) while (1) ; /* Enable LCD without voltage boost */ SegmentLCD_Init(false); while (1) { SegmentLCD_Number(i); Delay(1000); lsb = (i >> 0) & 0xFF ; msb = (i >> 8) & 0xFF ; USART_Tx(uart,GENIE_WRITE_OBJ); checksum = GENIE_WRITE_OBJ; USART_Tx(uart,GENIE_OBJ_LED_DIGITS); checksum ^= GENIE_OBJ_LED_DIGITS; USART_Tx(uart,0); checksum ^=0; USART_Tx(uart,msb); checksum ^=msb; USART_Tx(uart,lsb); checksum ^=lsb; USART_Tx(uart,checksum); ++i; }Above is my code for sending command from Host to LCD. I did the same thing in reserve to receive the report back from LCD to Host but I failed.
Please guide me. Thank you