TODOPIC
Otros Microcontroladores / Dispositivos programables => Microcontroladores 8 bits => Mensaje iniciado por: IngRandall en 22 de Agosto de 2016, 17:35:22
-
Hola amigos del foro, esto iniciandome con los micros de Atmel y estoy intentando inicializar 2 uart, ya el primero me funciona bien, pero el segundo al parecer no esta iniciando correctamente, este es mi codigo para inicializarlos:
const usart_serial_options_t uart_serial_options = {
.baudrate = CONF_UART_BAUDRATE,
#ifdef CONF_UART_CHAR_LENGTH
.charlength = CONF_UART_CHAR_LENGTH,
#endif
.paritytype = CONF_UART_PARITY,
#ifdef CONF_UART_STOP_BITS
.stopbits = CONF_UART_STOP_BITS,
#endif
};
/* Configure console UART 1. */
stdio_serial_init(CONF_UART_1, &uart_serial_options);
sysclk_enable_peripheral_clock(COM_PORT_USART_1);
usart_enable_tx(COM_PORT_USART_1);
usart_enable_rx(COM_PORT_USART_1);
usart_enable_interrupt(COM_PORT_USART_1, US_IER_RXRDY);
NVIC_EnableIRQ(USART1_IRQn);
/* Configure console UART 2. */
stdio_serial_init(CONF_UART_2, &uart_serial_options);//ESTA LINEA
sysclk_enable_peripheral_clock(COM_PORT_USART_2);
usart_enable_tx(COM_PORT_USART_2);
usart_enable_rx(COM_PORT_USART_2);
usart_enable_interrupt(COM_PORT_USART_2, US_IER_RXRDY);
NVIC_EnableIRQ(USART2_IRQn);
Si comento la primera linea de la configuración del uart 2 ("//ESTA LINEA") me funciona el uart 1 pero si la descomento el uart 1 no funciona.
Y el uart 2 hasta ahora no he podido leer nada.
Espero que me puedan ayudar, gracias.
-
Ya resolvi el problema, solo faltaba esto:
ioport_set_pin_peripheral_mode(COM_PORT_RX_PIN_2, COM_PORT_RX_MUX_2);
ioport_set_pin_peripheral_mode(COM_PORT_TX_PIN_2, COM_PORT_TX_MUX_2);
las definiciones son estas:
#define COM_PORT_USART_1 USART1
#define COM_PORT_USART_ID ID_USART1
#define COM_PORT_RX_PIN PIN_PC26A_USART1_RXD
#define COM_PORT_RX_GPIO GPIO_PC26A_USART1_RXD
#define COM_PORT_RX_MUX MUX_PC26A_USART1_RXD
#define COM_PORT_TX_PIN PIN_PC27A_USART1_TXD
#define COM_PORT_TX_GPIO GPIO_PC27A_USART1_TXD
#define COM_PORT_TX_MUX MUX_PC27A_USART1_TXD
#define COM_PORT_USART_2 USART2
#define COM_PORT_USART_ID_2 ID_USART2
#define COM_PORT_RX_PIN_2 PIN_PA19A_USART2_RXD
#define COM_PORT_RX_GPIO_2 GPIO_PA19A_USART2_RXD
#define COM_PORT_RX_MUX_2 MUX_PA19A_USART2_RXD
#define COM_PORT_TX_PIN_2 PIN_PA20A_USART2_TXD
#define COM_PORT_TX_GPIO_2 GPIO_PA20A_USART2_TXD
#define COM_PORT_TX_MUX_2 MUX_PA20A_USART2_TXD