2024-02-22 04:26 AM - edited 2024-02-23 05:09 AM
#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
2024-02-22 05:47 AM
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.