LCD programing example, Summaries of Embedded Systems

LCD programing example .......

Typology: Summaries

2022/2023

Uploaded on 11/02/2023

cuong-vu-4
cuong-vu-4 🇻🇳

3 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
#include "stm32f10x.h"
void delay_ms(uint16_t t);
void usart1_sendByte(unsigned char c);
int main()
{
RCC->APB2ENR |= 0xFC | (1<<14); //enable USART1 clocks
//USART1 init.
GPIOA->ODR |= (1<<10); //pull-up PA10
GPIOA->CRH = 0x444448B4; // RX1=input with pull-up, TX1=alt. func. output
USART1->CR1 = 0x200C; // USART enabled, transmitter is enabled, enable the receiver
USART1->BRR = 7500; // 72MHz/9600bps = 7500bit
while(1)
{
usart1_sendByte('H');
usart1_sendByte('i');
usart1_sendByte('\n'); //go to new line
usart1_sendByte('\r'); //carrier return
delay_ms(1000); //wait 1 second
}
}
void usart1_sendByte(unsigned char c)
{
USART1->DR = c;
while((USART1->SR&(1<<6)) == 0); //wait until the TC flag is set
}
void delay_ms(uint16_t t)
{
volatile unsigned long l = 0;
for(uint16_t i = 0; i < t; i++)
for(l = 0; l < 6000; l++)
{
}
}

Partial preview of the text

Download LCD programing example and more Summaries Embedded Systems in PDF only on Docsity!

#include "stm32f10x.h" void delay_ms(uint16_t t); void usart1_sendByte(unsigned char c); int main() { RCC->APB2ENR |= 0xFC | (1<<14); //enable USART1 clocks //USART1 init. GPIOA->ODR |= (1<<10); //pull-up PA GPIOA->CRH = 0x444448B4; // RX1=input with pull-up, TX1=alt. func. output USART1->CR1 = 0x200C; // USART enabled, transmitter is enabled, enable the receiver USART1->BRR = 7500; // 72MHz/9600bps = 7500bit while(1) { usart1_sendByte('H'); usart1_sendByte('i'); usart1_sendByte('\n'); //go to new line usart1_sendByte('\r'); //carrier return delay_ms(1000); //wait 1 second } } void usart1_sendByte(unsigned char c) { USART1->DR = c; while((USART1->SR&(1<<6)) == 0); //wait until the TC flag is set } void delay_ms(uint16_t t) { volatile unsigned long l = 0; for(uint16_t i = 0; i < t; i++) for(l = 0; l < 6000; l++) { } }