畅学ARM多功能实验箱数码管显示源码资源

来源:本站
导读:目前正在解读《畅学ARM多功能实验箱数码管显示源码资源》的相关信息,《畅学ARM多功能实验箱数码管显示源码资源》是由用户自行发布的知识型内容!下面请观看由(电工技术网 - www.9ddd.net)用户发布《畅学ARM多功能实验箱数码管显示源码资源》的详细说明。

畅学ARM多功能实验箱数码管显示源码资源

/******************LPC2103 spi口驱动74595 8位数码管显示实验*****************

//

//系统设置: Fosc、Fcclk、Fcco、Fpclk

//#define Fosc 12000000

//#define Fcclk (Fosc * 5)

//#define Fcco (Fcclk *4)

//#define Fpclk (Fcclk / 4) * 4

//Fpclk=60000000

接线说明: 使用 3根 1P杜邦线连接核心板 P04/P06/P07口接底板 JP26

具体接线为:P04-SHCP,P06-DS , P07-STCP。

跳线说明:短接 J70

实验现象:数码管先逐段扫描,然后显示0-9

技术网站:http://www.ippipp.com

淘宝店铺:http://cepark.taobao.com

作者:eeskill

时间:2017.07.01

*************************************************************/

#define IN_MAIN

#include "config.h"

#include "LPC2103_lian.H"

#include "ADC.h"

#include "ExtInterrupt.h"

#include "I2C.h"

#include "IAP.h"

#include "Legacy_GPIO.h"

#include "RTC.h"

#include "SPI.h"

#include "SSP.h"

#include "Time.h"

#include "UART.h"

#include "WatchDog.h"

#include "ISR.h"

#pragma import(__use_no_semihosting_swi)

#define rclk_0() IO0CLR=IO0CLR|p07 //74959锁存时钟

#define rclk_1() IO0SET=IO0SET|p07

const uint8 tb[]={

0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,

0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,

0x88,0x83,0xc6,0xa1,0x86,0x8e,0x00,

};

const uint8 smg_text[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,};

const uint8 smg[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0x00,};

// 0 1 2 3 4 5 6 7 8 9 all

const uint8 smg_bit[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0xff,};

uint8 c;

uint8 d;

void IRQ_Exception(void)

{

}

//**********************函数定义************************

void delay(uint32 dly);

void spiinit(void);

uint8 senddata_mspi(uint8 uiData);

//**********************主函数**************************

void Main(void)

{

TargetInit(VPBDIV_DATA, PLLCFG_DATA, MAMTIM_DATA); // don't delete

while((PLLSTAT & (1 << 10)) == 0); // can delete

p04_sck0;

p06_mosi0;

p05_miso0;

p07_gpio; //将端口设置为gpio口

gpio_out(p07); //设置为输出

delay(1);

spiinit();

for(d=0;d<8;d++)

{

for(c=0;c<8;c++)

{

rclk_0();

senddata_mspi(smg_bit[d]);

senddata_mspi(smg_text[c]);

rclk_1();

delay(200);

}

}

while(1)

{

for(c=0;c<11;c++)

{

rclk_0();

senddata_mspi(smg_bit[8]);

senddata_mspi(smg[c]);

rclk_1();

delay(200);

delay(200);

delay(200);

}

}

}

//*********************初始化SPI接口********************

void spiinit(void)

{

SPI_SPCCR=8; //设置SPI时钟分频,该值必须为大于等于8的偶数(该值越大,spi时钟越低)

SPI_SPCR =0<<2 | //每次传输8位数据

0<<3 | //CPHA=0,第一边沿采样.CPHA=1,第二边沿采样

0<<4 | //spi总线空闲时,CPOL=1,时钟为高电平.CPOL=0,时钟为低电平

1<<5 | //MSTR=1,设置为主模式

0<<6 | //LSBF=0,SPI传输MSB在先

0<<7 ; //SPIE=0,SPI中断禁止

}

//******************spi主机发送接收数据*****************

uint8 senddata_mspi(uint8 uiData)

{

SPI_SPDR=uiData;

while((SPI_SPSR&0x80)==0); //等待数据发送完毕

return(SPI_SPDR);

}

//************************延时**************************

void delay(uint32 dly)

{

uint32 i;

for(;dly>0;dly--)

{

for(i=0;i<5000;i++);

}

}

提醒:《畅学ARM多功能实验箱数码管显示源码资源》最后刷新时间 2024-03-14 00:52:38,本站为公益型个人网站,仅供个人学习和记录信息,不进行任何商业性质的盈利。如果内容、图片资源失效或内容涉及侵权,请反馈至,我们会及时处理。本站只保证内容的可读性,无法保证真实性,《畅学ARM多功能实验箱数码管显示源码资源》该内容的真实性请自行鉴别。