// ****************************************************************************************** // Project : STM32VLDISCOVERY Sample Program (STM32F100RB) // Program Name : // Programer : // Create date : Version 1.0 H24.10.01 // History : // Laungage : // ****************************************************************************************** // Description // On board LED : PC8, PC9 // // ****************************************************************************************** #include #include "stm32f10x.h" void timer(unsigned int); void M0puls(void); void M1puls(void); void M_hyp(unsigned int); void M_dot(unsigned int); void M_spe(unsigned int); void M_end(unsigned int); void M_out(char); void M_outs(char *); void Mintim(void); #define PI_SPEED 200 int main(void) { // ******************* // 1.Initialize // ******************* // (1)Define APB2(peripheral clock enable register) RCC->APB2ENR = 0x10; // APB2ENR[4]:IOPCEN I/O port C clock enable // Set and cleared by software. 0: I/O port C clock disabled, 1:I/O port C clock enabled // (2)Define I/O Port C // GPIOC->CRL // Port configuration register low (GPIOC[0-7]) GPIOC->CRH = 0x44444411; // Port configuration register high(GPIOC[8-15]) // CNF=00: General purpose output push-pull, MODE=01:Output mode, max speed 10 MHz // GPIOC->IDR // Port input data register (Read Only) IDR[31-16]:Reserved,@IDR[15-0]:Port output data GPIOC->ODR = 0x00000000; // Port output data register ODR[31-16]:Reserved,@ODR[15-0]:Port output data // GPIOC->BSRR // Port bit set/reset registe // GPIOC->BRR // Port bit reset register // GPIOC->LCKR // Port configuration lock register // ******************* // 2.Program main // ******************* while(1){ M_outs("ABCDEFGHIJKLMNOPQRSTUVWXYZ "); M_outs("1234567890 "); } } //**************************************************************************** // Function Name : M_outs // Title : // Input : // Output : // Description : //**************************************************************************** void M_outs(char in_char[] ) { unsigned int lp=0; while(in_char[lp]!=0x00){ M_out(in_char[lp]); lp++; } } //**************************************************************************** // Function Name : M_out // Title : // Input : // Output : // Description : //**************************************************************************** void M_out(char in_char ) { char m_data[15]; unsigned int lp; unsigned int Speed = PI_SPEED ; // ******************** // 1.Set data // ******************** if(in_char==' ') strcpy(m_data," "); if(in_char=='A') strcpy(m_data,"0-"); if(in_char=='B') strcpy(m_data,"-000"); if(in_char=='C') strcpy(m_data,"-0-0"); if(in_char=='D') strcpy(m_data,"-00"); if(in_char=='E') strcpy(m_data,"0"); if(in_char=='F') strcpy(m_data,"00-0"); if(in_char=='G') strcpy(m_data,"--0"); if(in_char=='H') strcpy(m_data,"0000"); if(in_char=='I') strcpy(m_data,"00"); if(in_char=='J') strcpy(m_data,"0---"); if(in_char=='K') strcpy(m_data,"-0-"); if(in_char=='L') strcpy(m_data,"0-00"); if(in_char=='M') strcpy(m_data,"--"); if(in_char=='N') strcpy(m_data,"-0"); if(in_char=='O') strcpy(m_data,"---"); if(in_char=='P') strcpy(m_data,"0--0"); if(in_char=='Q') strcpy(m_data,"--0-"); if(in_char=='R') strcpy(m_data,"0-0"); if(in_char=='S') strcpy(m_data,"000"); if(in_char=='T') strcpy(m_data,"-"); if(in_char=='U') strcpy(m_data,"00-"); if(in_char=='V') strcpy(m_data,"000-"); if(in_char=='W') strcpy(m_data,"0--"); if(in_char=='X') strcpy(m_data,"-00-"); if(in_char=='Y') strcpy(m_data,"-0--"); if(in_char=='Z') strcpy(m_data,"--00"); if(in_char=='0') strcpy(m_data,"-----"); if(in_char=='1') strcpy(m_data,"0----"); if(in_char=='2') strcpy(m_data,"00---"); if(in_char=='3') strcpy(m_data,"000--"); if(in_char=='4') strcpy(m_data,"0000-"); if(in_char=='5') strcpy(m_data,"00000"); if(in_char=='6') strcpy(m_data,"-0000"); if(in_char=='7') strcpy(m_data,"--000"); if(in_char=='8') strcpy(m_data,"---00"); if(in_char=='9') strcpy(m_data,"----0"); // ******************** // 2.Output // ******************** for(lp=0;lp<15;lp++){ switch(m_data[lp]){ case '0': M_dot(Speed); M_spe(Speed); break; case '-': M_hyp(Speed); M_spe(Speed); break; case ' ': M_end(Speed); break; default: M_end(Speed); return; } } } //**************************************************************************** // Function Name : M_hyp // Title : // Input : // Output : // Description : //**************************************************************************** void M_hyp(unsigned int len ) { unsigned int lp; len=len*3; for(lp=0;lpODR = 0x00000000; Mintim(); Mintim(); } //**************************************************************************** // Function Name : M1plus // Title : // Input : // Output : // Description : //**************************************************************************** void M1puls() { GPIOC->ODR = 0x00000300; Mintim(); Mintim(); GPIOC->ODR = 0x00000000; } //**************************************************************************** // Function Name : Mintim // Title : // Input : // Output : // Description : //**************************************************************************** void Mintim() { unsigned int lp,lp1; for(lp=0;lp<10;lp++) for(lp1=0;lp1<100;lp1++){}; }