2013-02-06 08:12 PM
I am trying to send data to a PC COM port but cannot figure it out
I configured GPIO, NVIC, and USART per specification and it all checks out. The strange thing is, when I connect the Tx pin and ground to oscilloscope, it shows that it is sending out data. However, on the other end, terminal software is not receiving any data.Any idea what is wrong? #gpio #nvic #uart #serial2013-02-06 08:18 PM
Is the bit time correct? Are the signals electrically compatible?
Find a working board/example, and compare/contrast with your circuit/software. Show your code, diagram your circuit, guessing is overrated.2013-02-06 10:46 PM
I am using this to configure serial communication and transmit data.
void SERIAL_Config(void){ GPIO_InitTypeDef GPIO_InitStructure; USART_InitTypeDef USART_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE); NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 3; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_USART1); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_OType = GPIO_OType_OD; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOA, &GPIO_InitStructure);*/ ///////////////////////////////////////// GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_USART1); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOA, &GPIO_InitStructure); //see stm32f4xx_usart USART_InitStructure.USART_BaudRate = SERIAL_BAUDRATE;//460800;//921600;//230400;//115200; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Tx; USART_Init(USART1, &USART_InitStructure); USART_Cmd(USART1, ENABLE); SERIAL_CallBack_InBufferAscii = NULL; SERIAL_CallBack_InbufferBinary = NULL;while(1){ USART_SendData(USART1, 'U'); while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);} }Is there anything here which might explain why the data is not received on the PC end?2013-02-07 02:45 AM
A broken cable, for example.
JW2013-02-07 04:31 AM
2013-02-07 04:32 AM
Is there anything here which might explain why the data is not received on the PC end?
Code doesn't appear unreasonable, suggest you look at the wiring, and the signals. Use a scope. If you don't wire the signals to the right destination. Won't Work If you push CMOS signals to a RS232 interface. Won't Work If you push Transmit of the source, to physical Transmit of the destination. Won't Work If you don't have a common ground connection. Won't Work2013-02-07 07:41 AM
Beyond advice/guidance given - insure that you are sending ''normal'' text - not a Control Code or non-Ascii or char w/msb set. (i.e. 0X8X)
Update/Edit: Upon read of your code - see that you're sending ''U'' - which is ideal for scope presentation w/alternating up/down bits. Code shows ''SERIAL_BAUDRATE'' - cannot find that define. Suggest that you start far slower (9600) to lessen effects of capacitance and cable limitations. Also - may help to add normal LF/CR - just in case your PC set-up requires proper EOL (end of line) termination to display... PC side must be set to receive (usually) 8-N-1 - (8 data bits, No Parity, 1 Stop Bit). Also insure that PC has not defaulted to, ''Flow Control.'' Either HW or SW Flow Control can confound your early efforts.2013-02-07 07:57 AM
If this is STM32F4-Discovery board there is a large capacitor on one of the USART1 pins as I recall.
Again some specificity about the board and wiring may assist resolution.