2020-03-24 08:50 PM
I'm trying to transmit some characters to the PC COM port from the STM32F407DISC1 board through USART2, but no data is seen on Tera Term.
The board is connected to the PC through USB connector "CN1" (mini-B type), hte same used to download the program. Should I use USB connector "CN5" (micro-B type) instead?
DOes anyone have a clue about it?
Below I attach the code.
Regards.
#include "stm32f4xx.h"
void USART2_Init(void);
void USART2_write(int ch);
void delayMs(int delay);
int main(void){
USART2_Init();
while(1){
USART2_write('h');
USART2_write('i');
delayMs(50);
}
}
void USART2_Init(void){
RCC->APB1ENR |= 0x20000;
RCC->AHB1ENR |= 1;
GPIOA->AFR[0] = 0x0700;
GPIOA->MODER |= 0x0020;
USART2->BRR = 0x0683;
USART2->CR1 = 0x0008;
USART2->CR1 |= 0x2000;
}
void USART2_write(int ch){
while(!(USART2->SR & 0x0080));
USART2->DR = (ch & 0xFF);
}
void delayMs(int delay){
int i;
for(; delay>0; delay--){
for(i=0; i<3195; i++);
}
}
2020-03-24 09:56 PM
And how do you have the USART2 connected to PC?
Note that on that board STLink's VCP pins are not connected to target, see the Disco board's user manual.
JW