
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
LCD programing example .......
Typology: Summaries
1 / 1
This page cannot be seen from the preview
Don't miss anything!

#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++) { } }