cancel
Showing results for 
Search instead for 
Did you mean: 

unable to send data to the data register of uart4

ganesh_jaina
Associate

#include "stm32f4xx.h"

#include<stdint.h>

 

 

void config_gpio()

{

RCC->AHB1ENR |= (1U<<0);//ENABLING THE PORT A

 

 

GPIOA->MODER |= (1U<<1);

GPIOA->MODER &= ~(1U<<0);//SETTING PA0 AS ALTERNATE FUNCTION MODE

 

 

GPIOA->OTYPER &= ~(1U<<0);//SETTING OUTPUT TYPE AS PUSH PULL

 

 

GPIOA->OSPEEDR |= (1U<<0)|(1U<<1);//VERY HIGH SPEED MODE

 

 

GPIOA->AFR[0] |= (1U<<3);

GPIOA->AFR[0] &= ~(1U<<0);

GPIOA->AFR[0] &= ~(1U<<1);

GPIOA->AFR[0] &= ~(1U<<2);//SETTING THE ALTERNATE FUNCTION 8

}

 

 

 

 

 

void uart4_config()

{

config_gpio();

RCC->APB1ENR |= (1U<<19);//ENABLING UART4

 

 

 

UART4->CR1 |= (1U<<3);//ENABLING TE WE ARE SENDING FIRST FRAME AS BLANK FRAME

UART4->CR2 &= ~(1U<<12);

UART4->CR2 &= ~(1U<<13);

UART4->BRR |= 0X0683;//16MHZ AND 9600 BAUD RATE

UART4->CR1 |= (1U<<13);//ENABLING THE UART

UART4->CR1 &= ~(1U<<12);

 

}

 

void transmit_byte(char ch)

{

// uint8_t temp = UART4->SR;

while(!(UART4->SR & (1U<<7)));

UART4->DR = (ch & 0xFF);

}

void uart_tran_string(const char *myString) /////to print any string

{

while (*myString)

transmit_byte(*myString++);

while(!(UART4->SR & (1U<<6)));

 

}

 

 

int main()

{

uart4_config();

uart_tran_string("hello");

}

*********************************************************************************

This is the code I am trying to implement I am trying to send data using uar4 but unable to 

 

1 REPLY 1
TDK
Guru

DR is not an address in RAM, it is an interface to the peripheral. You won't see the values you write to that register.

If you feel a post has answered your question, please click "Accept as Solution".