I have been working on a project which needs to use the UART. I have referenced many different sources and am confident that the USART is setup correctly. I have been running through the code on the debugger and I noticed that my xmitbuffer is properly filling. I am trying to print hello in a loop and as I go through the code the buffer gets filled with HelloHelloHello. This matches what is expected. However, nothing shows up on the terminal. I have tried putty as well as TeraTerm.
I looked at the status register for USART1 and the TX bit is set to 1. I assume the 1 indicates that the transmit is complete. I have tried it with baud rates of 9600 and 115200 and neither have had any success. I am not sure how to continue.
It is also import to note the cable I am using to send the USART to the PC. I am using the USB-RS232-WE-1800-BT_0.0 from FTDI (http://www.ftdichip.com/Products/Cables/USBRS232.htm) I am thinking that this could be my error. Does this cable work for this application? Do I need a TTL cable instead?
All the setup is below as well as my main function.
USART Setup:
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
USART_InitStruct.USART_BaudRate = 9600;
USART_InitStruct.USART_WordLength = USART_WordLength_8b;
USART_InitStruct.USART_StopBits = USART_StopBits_1;
USART_InitStruct.USART_Parity = USART_Parity_No ;
USART_InitStruct.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_InitStruct.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_Init(USART1, &USART_InitStruct);
USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);
USART_Cmd(USART1, ENABLE);
GPIO Setup: Most of this is for other devices. Port A pins 9 and 10 are the USART TX and RX pins that we are using.
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);
GPIO_A.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_15;
GPIO_A.GPIO_Mode = GPIO_Mode_IN;
GPIO_A.GPIO_Speed = GPIO_Speed_Level_2;
GPIO_A.GPIO_OType = GPIO_OType_PP;
GPIO_A.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_B.GPIO_Pin = GPIO_Pin_All;
GPIO_B.GPIO_Mode = GPIO_Mode_IN;
GPIO_B.GPIO_Speed = GPIO_Speed_Level_2;
GPIO_B.GPIO_OType = GPIO_OType_PP;
GPIO_B.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_C.GPIO_Pin = GPIO_Pin_All;
GPIO_C.GPIO_Mode = GPIO_Mode_IN;
GPIO_C.GPIO_Speed = GPIO_Speed_Level_2;
GPIO_C.GPIO_OType = GPIO_OType_PP;
GPIO_C.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOA, &GPIO_A);
GPIO_Init(GPIOB, &GPIO_B);
GPIO_Init(GPIOC, &GPIO_C);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource1, GPIO_AF_1);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_1);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_1);
Main:
void main(void)
{
initMicro();
while(1)
{
printf("Hello");
}
}