2386 views|1 replies

111

Posts

0

Resources
The OP
 

MM32F103 digital tube dynamic drive demonstration [Copy link]

This post was last edited by serialworld on 2018-11-1 06:29 The MM32F103 digital tube dynamic drive demonstration is relatively simple, so I won't explain it in detail. In addition, the current of the 96Mhz microcontroller running at full speed was tested. It was about 13.5mA at 5V. It could not be measured with a multimeter at 3.3V. It should be that the interference of the test leads was too large, and the microcontroller could not start normally.
  1. #include "delay.h" #include "sys.h" #include "led.h" #include "key.h" #include "uart.h" #include "uart_nvic.h" #include<stdio.h>
  2. #include <unistd.h>
  3. void LED_display(uint16_t data); void LED_c(uint16_t data); void LED_4(void); void LED_5(void); void LED_6(void); uint8_t LED_buffer[4] = { 0xa1 }; int _write(int32_t fd, char* ptr, int32_t len) { if (fd == STDOUT_FILENO || fd == STDERR_FILENO) { int32_t i = 0; while (i &lt; len) { while (UART_GetFlagStatus(UART1, UART_IT_TXIEN) == RESET) ; UART_SendData(UART1, (uint8_t) ptr[i++]); } } return len; } uint16_t dis_buffer[3] = { 0 }; int main(void) { u8 t = 0; u8 len; u16 times = 0; delay_init(); //delay function initialization LED_Init(); //initialize the hardware interface connected to the LED // KEY_Init(); //initialize the hardware interface connected to the key LED2 = 0; //Turn on the LED // uart_initwBaudRate(115200u); NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //Set interrupt priority group 2 uart_nvic_init(115200); //Initialize the serial port to 115200 while (1) { // t=KEY_Scan(0 ); //Get the key value if (UART_RX_STA &amp; 0x8000) { len = UART_RX_STA &amp; 0x3fff; //Get the length of the data received this time printf("\r\n your message is \r\n"); for (t = 0; t &lt; len; t++) { while (UART_GetFlagStatus(UART1, UART_IT_TXIEN) == RESET) ; UART_SendData(UART1, (u8) UART_RX_BUF[t]); } printf("\r\n\r\n"); //Insert newline UART_RX_STA = 0; } else { times++; if (times % 50 == 0) { printf("\r\n Serial port test\r\n"); dis_buffer[0] = (times / 50) % 10; dis_buffer[1] = (times / 50) % 10; dis_buffer[2] = (times / 50) % 10; dis_buffer[3] = (times / 50) % 10; // delay_ms(10); } if (times % 200 == 0) printf("please input date\r\n"); if (times % 30 == 0) LED2 = !LED2; //Flash LED to indicate that the system is running. } LED_4(); // LED_6(); } } void LED_display(uint16_t data ) { switch (data) { case 0: led_a = !1; led_b = !1; led_c = !1; led_d = !1; led_e = !1; led_f = !1; led_g = !0; led_dp = !0; break; case 1: led_a = !0; led_b = !1; led_c = !1; led_d = !0; led_e = !0; led_f = !0; led_g = !0; led_dp = !0; break; case 2: led_a = !1; led_b = !1; led_c = !0; led_d = !1; led_e = !1; led_f = !0; led_g = !1; led_dp = !0; break; case 3: led_a = !1; led_b = !1; led_c = !1; led_d = !1; led_e = !0; led_f = !0; led_g = !1; led_dp = !0; break; case 4: led_a = !0; led_b = !1; led_c = !1; led_d = !0; led_e = !0; led_f = !1; led_g = !1; led_dp = !0; break; case 5: led_a = ! 1; led_b = !0; led_c = !1; led_d = !1; led_e = !0; led_f = !1; led_g = !1; led_dp = !0; break; case 6: led_a = !1; led_b = !0; led_c = !1; led_d = !1; led_e = !1; led_f = !1; led_g = !1; led_dp = !0; break; case 7: led_a = !1; led_b = !1; led_c = !1; led_d = !0; led_e = !0; led_f = !0; led_g = !0; led_dp = !0; break; case 8: led_a = !1; led_b = !1; led_c = !1; led_d = !1; led_e = !1; led_f = !1; led_g = !1; led_dp = !0; break; case 9: led_a = !1; led_b = !1; led_c = !1; led_d = !1; led_e = !0; led_f = !1; led_g = !1; led_dp = !0;
  4.                 break;
  5.         default:
  6.                 break;
  7.         }
  8.         return;
  9. }
  10. void LED_c(uint16_t data) {
  11.         switch (data) {
  12.         case 0:
  13.                 led_c1 = 0;
  14.                 led_c2 = 1;
  15.                 led_c3 = 1;
  16.                 led_c4 = 1;
  17.                 break;
  18.         case 1:
  19.                 led_c1 = 1;
  20.                 led_c2 = 0;
  21.                 led_c3 = 1;
  22.                 led_c4 = 1;
  23.                 break;
  24.         case 2:
  25.                 led_c1 = 1;
  26.                 led_c2 = 1;
  27.                 led_c3 = 0;
  28.                 led_c4 = 1;
  29.                 break;
  30.         case 3:
  31.                 led_c1 = 1;
  32.                 led_c2 = 1;
  33.                 led_c3 = 1;
  34.                 led_c4 = 0;
  35.                 break;
  36.         default:
  37.                 led_c1 = 1;
  38.                 led_c2 = 1;
  39.                 led_c3 = 1;
  40.                 led_c4 = 1;
  41.                 break;
  42.         }
  43.         return;
  44. }
  45. void LED_4(void) {
  46.         uint16_t i;
  47.         for (i = 0; i &lt; 4; i++) {
  48.                 LED_c(i);
  49.                 LED_display(dis_buffer[i]);
  50.                 delay_ms(2);
  51.         }
  52. //        LED_c(i);
  53.         return;
  54. }
  55. void LED_5(void) {
  56.         int i;
  57.         for (i = 0; i &lt; 1; i++) {
  58.                 led_a = !((LED_buffer[0] &gt;&gt; 0) &amp; 0x01);
  59.                 delay_ms(2);
  60.                 led_b = !((LED_buffer[0] &gt;&gt; 1) &amp; 0x01);
  61.                 delay_ms(2);
  62.                 led_c = !((LED_buffer[0] &gt;&gt; 2) &amp; 0x01);
  63.                 delay_ms(2);
  64.                 led_d = !((LED_buffer[0] &gt;&gt; 3) &amp; 0x01);
  65.                 delay_ms(2);
  66.                 led_e = !((LED_buffer[0] &gt;&gt; 4) &amp; 0x01);
  67.                 delay_ms(2);
  68.                 led_f = !((LED_buffer[0] &gt;&gt; 5) &amp; 0x01);
  69.                 delay_ms(2);
  70.                 led_g = !((LED_buffer[0] &gt;&gt; 6) &amp; 0x01);
  71.                 delay_ms(2);
  72.         }
  73. }
  74. void LED_6(void) {
  75.         uint16_t i;
  76.         for (i = 0; i &lt; 4; i++) {
  77.                 LED_c(i);
  78. //                LED_display(dis_buffer[i]);
  79.                 LED_5();
  80.                 delay_ms(2);
  81.         }
  82. //        LED_c(i);
  83.         return;
  84. }
复制代码



此内容由EEWORLD论坛网友serialworld原创,如需转载或用于商业用途需征得作者同意并注明出处u

led.PNG (1.16 MB, downloads: 0)

led.PNG

Latest reply

  Details Published on 2018-10-31 22:05
 
 

152

Posts

0

Resources
2
Personal signature

欢迎大家来到电机驱动控制技术天地,一起在EEworld交流、学习。

 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list