Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years, 8 months ago.
MODSERIAL port works for printf and getc etc but hangs when I change baud etc.
My MODSERIAL port seems to work when I do things like pc.putc(pc.getc()); and pc.printf("test"); but hangs when I do things like pc.baud(115200); and pc.format(8, Serial::Even, 2);.
What is likely to be the problem ?
My MODSERIAL port files below.
.h file
- ifdef TARGET_NUCLEO_F767ZI
- define MODSERIAL_IRQ_REG ((USART_TypeDef*)_base)->CR1
- define DISABLE_TX_IRQ MODSERIAL_IRQ_REG &= USART_CR1_TXEIE
- define DISABLE_RX_IRQ MODSERIAL_IRQ_REG &= USART_CR1_RXNEIE
- define ENABLE_TX_IRQ MODSERIAL_IRQ_REG |= USART_CR1_TXEIE
- define ENABLE_RX_IRQ MODSERIAL_IRQ_REG |= USART_CR1_RXNEIE
- define MODSERIAL_READ_REG ((USART_TypeDef*)_base)->RDR
- define MODSERIAL_WRITE_REG ((USART_TypeDef*)_base)->TDR
- define MODSERIAL_READABLE ((((USART_TypeDef*)_base)->ISR & USART_ISR_RXNE) != 0)
- define MODSERIAL_WRITABLE ((((USART_TypeDef*)_base)->ISR & USART_ISR_TXE) != 0)
- define RESET_TX_FIFO while(0 == 1)
- define RESET_RX_FIFO while(MODSERIAL_READABLE) char dummy = MODSERIAL_READ_REG
- define RX_IRQ_ENABLED ((MODSERIAL_IRQ_REG & USART_CR1_RXNEIE) != 0)
- define TX_IRQ_ENABLED ((MODSERIAL_IRQ_REG & USART_CR1_TXEIE) != 0)
- endif
- ifdef TARGET_NUCLEO_F767ZI
- include "MODSERIAL.h"
.cpp file void MODSERIAL::setBase(void ) { switch( _serial.index ) { switch( _serial.serial.index ) {
case 0: _base = USART1; _IRQ = USART1_IRQn; break; case 1: _base = USART2; _IRQ = USART2_IRQn; break; case 2: _base = USART3; _IRQ = USART3_IRQn; break; case 3: _base = USART6; _IRQ = USART6_IRQn; break; default: _base = NULL; _IRQ = (IRQn_Type)NULL; break; } }
void MODSERIAL::initDevice(void) {};
bool MODSERIAL::txIsBusy( void ) { return ( (((USART_TypeDef*)_base)->ISR & ( 1UL << 6 )) == 0 ) ? true : false; }
- endif
I hadn't added in the UART's.
void MODSERIAL::setBase(void ) { switch( _serial.index ) { switch( _serial.serial.index ) {
case 0: _base = USART1; _IRQ = USART1_IRQn; break; case 1: _base = USART2; _IRQ = USART2_IRQn; break; case 2: _base = USART3; _IRQ = USART3_IRQn; break; case 3: _base = UART4; _IRQ = UART4_IRQn; break; case 4: _base = UART5; _IRQ = UART5_IRQn; break; case 5: _base = USART6; _IRQ = USART6_IRQn; break; case 6: _base = UART7; _IRQ = UART7_IRQn; break; case 7: _base = UART8; _IRQ = UART8_IRQn; break; default: _base = NULL; _IRQ = (IRQn_Type)NULL; break; } }
void MODSERIAL::initDevice(void) {};
bool MODSERIAL::txIsBusy( void ) { return ( (((USART_TypeDef*)_base)->ISR & ( 1UL << 6 )) == 0 ) ? true : false; }
- endif
posted by David Fisher 06 Apr 2017