Answered You can hire a professional tutor to get the answer.

QUESTION

I have done the UART message transmission test which I pasted below. Port C 11 - UART4 _RX/ is for receiving. Please use STM32 M cortex.

I need help with getting the UART message for receiving test. I have done the UART message transmission test which I pasted below. Port C 11 - UART4 _RX/ is for receiving. Please use STM32 M cortex. 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 ''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]==''){   i=0;  }else{   UART4->DR = DataString[i];   i++;  }}

}

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question