cancel
Showing results for 
Search instead for 
Did you mean: 

Usart3 communication with st link

mani s
Associate III
Posted on July 04, 2018 at 09:59

I have implemented usart in stm32f746 series ,i'm using usart3 pd8 and pd9 port but it is not sending any data to serial port (putty im using),my doubt is should i connect  usb to ttl conveter to these particular pins or just st link is enough to get data of any usart serially ?

i post code in a while 

5 REPLIES 5
mani s
Associate III
Posted on July 13, 2018 at 07:54

this is code below for usart2 communication but i could not see anything on putty.please where is the wrong in the code 

#include 'stm32f7xx.h' // Device header

#include<stdint.h>

#include 'Board_LED.h'

#include <string.h>

#include <stdio.h>

int rec_data();

void send_data(char s);

void delay();

void flash_led();

void PutString( uint8_t * str);

int main()

{

// int a, n;

// float b;

LED_Initialize();

//flash_led();

//usart_snd_str('\n\rHello, please type something\n\r');

//reset clock reg

RCC -> AHB1ENR |= RCC_AHB1ENR_GPIODEN;

//reset and clock control reg ,select USART2 for APB1, pin no 18

RCC -> APB1ENR =RCC_APB1ENR_USART2EN;

// mode pd8- tx and pd9 - rx

GPIOA -> MODER &= ~(GPIO_MODER_MODER1_0);

GPIOA -> MODER |= GPIO_MODER_MODER1_1;

//alternate function A7

// GPIOA->AFR[0] |= 0x77 << (4*5);

//type of gpio alternate function

GPIOA -> OTYPER &= ~(GPIO_OTYPER_OT_2);

GPIOA -> OTYPER &= ~(GPIO_OTYPER_OT_3);

//speed

GPIOA -> OSPEEDR |= GPIO_OSPEEDER_OSPEEDR1;

//push pull resisitor

GPIOA -> PUPDR &= ~(GPIO_PUPDR_PUPDR1);

//uart_configration();

// start bit

//data word length 7 , 8 and 9

//stop 2 nd 1

//baud rate 9600

//parity bits

//mode

USART2 -> CR1 &= ~USART_CR1_M0;

USART2 -> BRR = 9600;

USART2 -> CR2 &= ~(USART_CR2_STOP_1);

USART2 -> CR1 &= ~(USART_CR1_OVER8);

USART2 -> CR1 |= (USART_CR1_TE | USART_CR1_RE );

USART2 -> CR1 |= USART_CR1_UE;

uint8_t a= 12;

PutString(&a);

}

void PutChar(int8_t ch)

{

while(!(USART2->ISR & USART_ISR_TXE));

USART2->TDR = ch;

}

void PutString( uint8_t * str)

{

while(*str != 0)

{

PutChar( *str);

str++;

}

}

int rec_data()

{

/* Wait until the data is ready to be received. */

while (!(USART2->ISR & USART_ISR_RXNE));

// read RX data, combine with DR mask (we only accept a max of 9 Bits)

return ((uint8_t)(USART2->RDR & 0xFF));

}

void flash_led()

{

LED_On(1);

delay();

LED_Off(1);

delay();

}

void delay()

{

for(int i=0;i<500000;i++);

}
AvaTar
Lead
Posted on July 13, 2018 at 08:36

I have implemented usart in stm32f746 series ,i'm using usart3 pd8 and pd9 port ...

What board, i.e. what is connected to this pins ?

... but it is not sending any data to serial port (putty im using) ...

Do you guess or do you know ?

Use a scope to check for the signals on TX.

For RS232, you need a level converter, the 3.3V from the STM32 is not enough to drive this logic.

The PC terminal software (PuTTY) is just the final element in this chain, usually it's broken way before.

Posted on July 13, 2018 at 09:17

we have debug option in keil ide ,the data is tranfering to TDR registers but in serial terimnal it is not coming data which i m sending .I'm using stm32f746 series board .I have connected to Usart2  comm. im using stlink to communicate

Posted on July 13, 2018 at 09:42

I'm using stm32f746 series board .I have connected to Usart2  comm. im using stlink to communicate

I interpret this a connection to the VCP port of the ST-Link, which works with board levels (3.3V).

You can check the TX pin (PD8) with a scope or logic analyzer.

If you send something from PuTTY, you should see the signals on RX (PD9).

Sorry, I'm not going to cross-read the reference manual to decode your magic-number-register-write UART initialization.

If you don't see anything on TX, you probably miss something at init.

Pick a working example to start with, if necessary from Cube.

Posted on July 13, 2018 at 09:56

i will try from cue , i dont have logic analyzer