Professional Documents
Culture Documents
Taller Uart-1
Taller Uart-1
h>
#include "STM32F7XX.h"
char dataRx;
int time =1000;
int j=0;
char dataTx = '$';
char helloMessage[] = {"HELLO THERE \rToday is..\r"};
int cont = 0;
int conts=0;
int ini = 0;
char limi =9;
//LCD
char clear =0x01;
char home =0x02;
char set = 0x3C;
char disp_on=0x0F;
char disp_off=0x08;
char mode_set1=0x06;
char mode_set2=0x04;
char disp_shift =0x1C;
char disp_shift1=0x18;
void sendMsg(){
int i=0;
int lengthMsg=sizeof(helloMessage);
for (i=0;i<lengthMsg-1;i++){
dataTx = helloMessage[i];
UART4->TDR=dataTx; //REGISTRO AL CUAL SE ESCRIBE
while ((UART4->ISR &= 0x80)==0); // ESPERA A QUE TXE SEA 1
}
}
extern "C" {
void SysTick_Handler(void){
if(ini==1){
cont++;
if (cont>999){
conts++;
comando_lcd(wlinea_1);
dato_lcd(conts+48);
if (48+conts>limi-1){
sendMsg();
comando_lcd(wlinea_2+6);
dato_lcd('F');
dato_lcd('i');
dato_lcd('n');
conts=0;
ini=0;
}
cont=0;
}
}
}
void UART4_IRQHandler(void){ //UART interruption implementation
}
ini=1;
comando_lcd(clear);
comando_lcd(wlinea_1);
dato_lcd(0+48);
limi=dataRx;
}
int main(void){
//clock eneable puerto A,B Y C
RCC->AHB1ENR |= (1UL<<0);
RCC->AHB1ENR |= (1UL<<1);
RCC->AHB1ENR |= (1UL<<2);
//SysTick
SysTick_Config (SystemCoreClock/1000);
SystemCoreClockUpdate();
comando_lcd(clear);
comando_lcd(home);
comando_lcd(set);
comando_lcd(disp_on);
comando_lcd(mode_set1);
comando_lcd(wlinea_1);
while(true){
}
}