I need help with getting the UART message to recieve a commu

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++;
  }
}

}

Solution

TRY THIS CODE

\'PIC16F887 @8MHz
\'RB0-RB5- LCD 4-bit

program Custom_char_LCD_UART

\'*********** UART *******
dim procitana_vr as byte
\'********************
dim row as integer
dim col as integer
dim i as char
  
dim LCD_RS as sbit at RB0_bit
LCD_EN as sbit at RB1_bit
LCD_D4 as sbit at RB2_bit
LCD_D5 as sbit at RB3_bit
LCD_D6 as sbit at RB4_bit
LCD_D7 as sbit at RB5_bit

LCD_RS_Direction as sbit at TRISB0_bit
LCD_EN_Direction as sbit at TRISB1_bit
LCD_D4_Direction as sbit at TRISB2_bit
LCD_D5_Direction as sbit at TRISB3_bit
LCD_D6_Direction as sbit at TRISB4_bit
LCD_D7_Direction as sbit at TRISB5_bit
\'********* LCD **********
\'***********Random character*************
const character as byte[8] = (10,4,14,17,10,4,17,0)

sub procedure Tabla(dim pos_row as byte, dim pos_char as byte)
dim i as byte
Lcd_Cmd(64)
for i = 0 to 7
Lcd_Chr_CP(character[i])
next i
Lcd_Cmd(_LCD_RETURN_HOME)
Lcd_Chr(pos_row, pos_char, 0)
end sub


\'*********** Delay line **************
sub procedure Pauza_100()
Delay_ms(100)
end sub
sub procedure Pauza_500()
Delay_ms(500)
end sub
sub procedure Pauza_2000()
Delay_ms(2000)
end sub
\'********************************

main:
TRISB = 0
PORTB = 0
ANSEL = 0
ANSELH = 0
UART1_Init(9600)
Pauza_100()
row = 1
col = 1

Lcd_Init() \'From here starts the code for the communication
Lcd_Cmd(_LCD_CLEAR)
Lcd_Cmd(_LCD_CURSOR_OFF)
Tabla(1, 1)
Tabla(2, 1)
\'********** Some quick Test messages
Pauza_500()
Lcd_Cmd(_LCD_CLEAR)
Lcd_Cmd(_LCD_UNDERLINE_ON)
Lcd_Out(1, 2, \"TEST UART\")
Pauza_2000()
\'****************************************************************************************************
While (TRUE) \'Endless loop
if (UART1_Data_Ready()= 1) then
i = UART1_Read()
Lcd_Chr(row, col, i)
if(i = 27) then \' on ESC button (on keyboard), clear the LCD display :D
Lcd_Cmd(_LCD_CLEAR)
col = 1
row = 1
end if
UART1_Write(i)
col = col + 1
end if
\'****************************************************************************************************
Pauza_100()
\'****************************************************************************************************
if col = 17 then \'When it reaches the end go to next row
if row = 1 then \'if it reaches the end of first row go to second
row = 2
col = 1
end if
end if
Pauza_100()
\'****************************************************************************************************
if row = 2 then \'If the whole display is with some message on it (FULL)
if col = 17 then \'Clear it
Lcd_Cmd(_LCD_CLEAR)
col = 1
row = 1
end if
end if
\'****************************************************************************************************
wend
end.

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 -
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 -
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 -
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 -

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site