仅供参考:
单片机源程序如下:
- #include <STC32G.h>
- #include <intrins.h>
- #define MAIN_Fosc 11059200L //定义主时钟
- typedef unsigned char u8;
- typedef unsigned int u16;
- typedef unsigned long u32;
- #include "delay.h"
- #include "max7219.h"
- void main(void)
- {
- P0M1 = 0x00; P0M0 = 0x00; //设置为准双向口
- P1M1 = 0x00; P1M0 = 0x00; //设置为准双向口
- P2M1 = 0x00; P2M0 = 0x00; //设置为准双向口
- P3M1 = 0x00; P3M0 = 0x00; //设置为准双向口
- P4M1 = 0x00; P4M0 = 0x00; //设置为准双向口
- P5M1 = 0x00; P5M0 = 0x00; //设置为准双向口
- P6M1 = 0x00; P6M0 = 0x00; //设置为准双向口
- P7M1 = 0x00; P7M0 = 0x00; //设置为准双向口
- WTST = 0; //设置程序指令延时参数,赋值为0可将CPU执行指令的速度设置为最快
-
- delay1ms(10);
- Init_MAX7219();
- delay1ms(50);
- Write_data(0x0f, 0x00); //显示测试:1;测试结束,正常显示:0
- Write_data(1,6); //第8个字符,显示8
- Write_data(2,5);
- Write_data(3,0x3a);
- Write_data(4,4); //0x3a,显示为"-"
- Write_data(5,3);
- Write_data(6,0x3a);
- Write_data(7,2); //第2个字符,显示2
- Write_data(8,1); //第1个字符,显示1
-
- while(1);
- }
复制代码
Keil代码下载:
STC32G+MAX7219 串行数码管显示.7z
(22.6 KB, 下载次数: 54)
|