My controller is bgm113 and have uart databuss configured as follows:
USART_Reset(USART0); //Init variable CMU_ClockEnable(cmuClock_USART0,true); //Init usart to async mode, baudrate 115200 USART_InitAsync_TypeDef usart0_init = USART_INITASYNC_DEFAULT; usart0_init.enable = usartEnableTx; usart0_init.baudrate = UART_BAUDRATE; USART_InitAsync(USART0,&usart0_init); //eof async mode //binding gpio pin to usart peripheral USART0->ROUTEPEN |= USART_ROUTEPEN_TXPEN; uint32_t Pd13_asyncTxLoc = 21;//datasheet TX location 21, PD13 for USART0 async tx USART0->ROUTELOC0 = (USART0->ROUTELOC0 & ~(_USART_ROUTELOC0_TXLOC_MASK)) | (Pd13_asyncTxLoc << _USART_ROUTELOC0_TXLOC_SHIFT);//gpio binding happens here //interrupts for usart USART_IntClear(USART0,USART_IEN_TXBL); NVIC_ClearPendingIRQ(USART0_TX_IRQn); NVIC_EnableIRQ(USART0_TX_IRQn); USART_IntEnable(USART0,USART_IEN_TXBL);
Somehow there is periodical pulse in few u-seconds with this setting.
When I change the baudrate the period changes accordingly, also pulse width changes. Smaller baudrate gives bigger pulse width.
Do you have some knowledge on this matter?
Did I conf this wrong way?
Thank you for your inquiry about using the BGM113 USART in asynchronous mode. After looking at your configuration I have a few comments and questions:
1) Where do you observe the periodic pulse - i.e. is it on the USART0 TX pin (PD13)? How does the pulse relate to the baudrate (i.e. what is the period of the pulse at different baudrates)? If possible, please post a screen capture or photo of an oscilloscope capture of the periodic pulse.
2) Your GPIO binding in the USART0_ROUTEPEN and USART0_ROUTLOC0 registers appears correct, however you do not configure the pin in the GPIO module in your code snippet (i.e. enable clock to GPIO, set pin mode to push-pull). Do you do this elsewhere in your initialization code?
3) You should enable the USART0 clock before calling USART_Reset(USART0) or modifying any registers in the USART0 module.
4) Note that you enable to USART0 (because usart0_init.enable = usartEnableTx; and you call USART_InitAsync()) before you enable and configure the GPIO TX pin. This could cause glitches on the pin. You could consider setting usart0_init.enable = usartDisable in your init structure and then enabling the USART after you conbfigure the GPIO by calling:
Thank you, and let me know if you have any questions or if you have more details about the issue you are observing.