Tool/software:
Hi,
I am using MSPM0C1104 and there is only one uart available so I need to make GPIO SW uart. For this Timer interrupt GPIO Uart is used since gpio pins are asynchronous. Now in same project I have SW GPIO Uart and UART0 already available uart.
Now I am using polling method for Uart0 and Timer interrupt for SW Uart. But in while loop only HW uart is working if both uart is active, and sw gpio uart is working only when there is no other code in while loop.
Can you explain me how do I proceed this and send data to both the uart in while loop.
int main(void)
{
SYSCFG_DL_init();
/*
* Turn OFF LED if SW is open, ON if SW is closed.
* LED starts OFF by default.
*/
NVIC_EnableIRQ(GPIO_UART_INT_IRQN);
NVIC_EnableIRQ(TIMER_0_INST_INT_IRQN);
currentState = RX_STATE;
tx_data_buff = 0x21;
send_flag = 0;
unsigned char arr[] = {0x11,0x22, 0x77, 0x44 ,0x66, 0x88, 0x77,0x77,0x77,0x76,0x76,0x76,0x76};//OpenLid;
while (1) {
__WFI();
if(send_flag == 1)
{
tempByte = tx_data_buff << 1; // Store data bye and add start bit
tempByte |= 0x0200; // Add stop bit
send_flag = 0;
DL_GPIO_setPins(GPIO_UART_PORT, GPIO_UART_SW_TX_PIN);
DL_GPIO_initDigitalOutputFeatures(GPIO_UART_SW_TX_IOMUX,
DL_GPIO_INVERSION_DISABLE, DL_GPIO_RESISTOR_PULL_UP,
DL_GPIO_DRIVE_STRENGTH_LOW, DL_GPIO_HIZ_DISABLE);
DL_GPIO_enableOutput(GPIO_UART_PORT, GPIO_UART_SW_TX_PIN);
Timer_init();
currentState = TX_STATE;
}
else{
unsigned char arr[] = {0x11,0x22, 0x77, 0x44 ,0x66, 0x88, 0x77,0x77,0x77,0x76,0x76,0x76,0x76};//OpenLid;
uart_packet_size = sizeof(arr)/sizeof(arr[0]);
UART_Write_buffer(arr, uart_packet_size); //This is function to send data to uart which is working fine.
DL_GPIO_togglePins(GPIO_LEDS_PORT,
GPIO_LEDS_USER_LED_1_PIN | GPIO_LEDS_USER_TEST_PIN);
}
delay_cycles(1200000);
}
}
Here only else condition working. If I comment the else condition then only IF condition SW Uart is sending data.
How do I proceed this??????