Question: I need help with getting the UART message to recieve a communication on my LCD. I have done the UART message transmission test which I

I need help with getting the UART message to recieve a communication on my LCD. I have done the UART message transmission test which I pasted below. Port C 11 - UART4 _RX/ is for receiving. Please use STM32F4 discovery. Thanks.

* UART message transmission test * * Using UART4 for this exercise: * Port C10 - UART4_TX/ * Port C11 - UART4_RX/

*/

#include "stm32f4xx.h" // Device header

char DataString[] = "I am FUNKY!!"; // Init string & ptr ; // string must be terminated by '\0' int i=0;

int main(){

// ENABLE CLocks for PORT C and UART4 RCC->AHB1ENR |= 0x4; RCC->APB1ENR |= 0x80000; // Set Mode Pins on Port C pins 10 and 11 to Alternate Function GPIOC->MODER |= 0xa00000; // Set Alternate Function Register for Port C 10 and 11 // AF8 on AFRH GPIOC->AFR[1] |= 0x8800; // UART setup: // 8 data bits (default), no parity (default), one stop bit (default) & no flow control (default) UART4->CR1 &= ~(0x1000); UART4->CR2 &= ~(0x3000); //1 stop bit // UART Baud Rate = 19.2 Kbps UART4->BRR = 0x341; //from table value in BRR=52.0625 // Enable TRANSMITTER (TE bit) UART4->CR1 |= 0x8; // WE WANT TO TRANSMIT SO ENABLE TRANSMIT INTERRUPT UART4->CR1 |= 0x80; // Enable UART (UE bit in CR1 register) UART4->CR1 |= 0x2000; // NVIC to handle interrupts __enable_irq(); NVIC_ClearPendingIRQ(UART4_IRQn); NVIC_SetPriority(UART4_IRQn,0); NVIC_EnableIRQ(UART4_IRQn); while(1); }

// Interrupt reoutine for UART1

void UART4_IRQHandler(void){ // TX IRQ // If TXE flag in SR is on then NVIC_ClearPendingIRQ(UART4_IRQn); if((UART4->SR & 0x80)!=0){ if(DataString[i]=='\0'){ i=0; }else{ UART4->DR = DataString[i]; i++; } }

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!