Hellow everyone, I'm testing the UART communication between the MCU and the PC. There is communication in both directions, the problem is that even if you only press the keyboard once, the instruction (flashing a led) is repeated twice. Annex code and image of the terminal. Thank you very much for the help//MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN
void main(void)
{
//Variables locales.....................
uint8_t caracter;
// Configure TXD pin as output.
// P0.5, P0.3 and P1.0 are configured as outputs to make the example run on
// either 24-pin, 32-pin or 48-pin nRF24LE1 variants.
P0DIR = 0xD6; //1101 0110
P1DIR = 0xFE;
P0CON = 0x31; //0011 0000 + 1 Digital Input, buffer ON, Pull Down resistor connected
P00=0;
// Initializes the UART
hal_uart_init(UART_BAUD_9K6);
// Wait for XOSC to start to ensure proper UART baudrate
while(hal_clk_get_16m_source() != HAL_CLK_XOSC16M)
{}
// Enable global interrupts
EA = 1;
// Print "Lo que quieras" at start-up
putstring("\r\nRutina de Pruebas\r\n");
putstring("\r\nPara la Comunicacion UART\r\n");
for(;;)
{
putstring("\r\nMENU DE INICIO\r\n");
putstring("\r\n1. Parpadeo lento LED\r\n");
putstring("\r\n2. Parpadeo Rapido LED\r\n\n\n");
caracter = hal_uart_getchar(); // original: getchar();
printf("\r\nTu seleccion fue: %c \n\n\n\n", caracter);
// /*
switch (caracter)
{
case '1':
Parpadeo_LED();
caracter = 0;
break;
case '2':
Parpadeo_Rapido_LED();
caracter = 0;
break;
default:
putstring("\r\nSELECION NO VALIDA\r\n");
LED = 1;
delay_ms(1000);
LED = 0;
caracter = 0;
break;
}
// */
}
}//Fin MAIN Fin MAIN Fin MAIN Fin MAIN Fin MAIN Fin MAIN Fin MAIN Fin MAIN Fin MAIN Fin