本帖最后由 Nu_Micro 于 2014-11-7 17:39 编辑
程序简介:
基于NUC230_240BSP_CMSIS_V3.00.001;
初始化SPI及74HC595片选引脚:
SPI_Init();
GPIO_SetMode(PC, BIT2, GPIO_PMD_OUTPUT); //74HC595 latch pin
PC->DOUT&=~(1<<2); //init to low, high effect
GPIO_SetMode(PB, BIT4, GPIO_PMD_OUTPUT); //74HC595 clear pin
PB->DOUT|=(1<<4); //init to high, low affect
显示一个数字在点阵屏上,参数代表要显示的数字:
void ShowNum(uint8_t Number)
{
uint32_t i;
for(i=Number*7;i<(Number*7+7);i++)
{
PB->DOUT&=~(1<<4);
LoopDelay(1);
PB->DOUT|=1<<4;
LoopDelay(1);
SPI_WRITE_TX0(SPI0, NumDotMatrix);
SPI_TRIGGER(SPI0);
while(SPI_IS_BUSY(SPI0));
PC->DOUT|=1<<2;
LoopDelay(1);
PC->DOUT&=~(1<<2);
}
}
数字点阵表:
uint32_t NumDotMatrix[70]=
{
0x000001, 0x01FC02, 0x020204, 0x040108, 0x020210, 0x01FC20, 0x000040, //0
0x000001, 0x000002, 0x020104, 0x07ff08, 0x000110, 0x000020, 0x000040, // 1
0x000001, 0x030702, 0x040904, 0x041108, 0x022110, 0x01C120, 0x000040, // 2
0x000001, 0x018402, 0x020204, 0x042108, 0x045110, 0x038E20, 0x000040, // 3
0x000001, 0x00F802, 0x010804, 0x060808, 0x000810, 0x07FF20, 0x000840, // 4
0x000001, 0x07E102, 0x042104, 0x042108, 0x042110, 0x043F20, 0x000040, // 5
0x000001, 0x03FF02, 0x042104, 0x042108, 0x042110, 0x043F20, 0x000040, // 6
0x000001, 0x040002, 0x043f04, 0x044008, 0x048010, 0x070020, 0x000040, // 7
0x000001, 0x07ff02, 0x042104, 0x042108, 0x042110, 0x07ff20, 0x000040, // 8
0x000001, 0x07E102, 0x042104, 0x042108, 0x042110, 0x07ff20, 0x000040 // 9
};
|
|