This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSPM0C1104: GPIO SW UART

Part Number: MSPM0C1104

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??????

  • Hello Harshita,

    There are some points need you pay attention to, check and do :

    1). __WFI() means that MCU will enter low power mode and the program will get stuck here until an interrupt occurs.

    2). If you don't want you program to enter low power mode again after handling interrupt and want to let your program continue to execute the following statements, please add this instruction: DL_SYSCTL_disableSleepOnExit().

    3). Check your logic whether the interrupt will occur when your program is executing the "if" and "else".

    4). It seems that the send_flag is very important for your program, i think you can check the logic of send_flag whether it is set at the time point you need.

    5). Try to test UART0 and SW UART separately.

    Best Regards,

    Janz Bai