AVR128的程序——DS1302时钟芯片
#include
#define uchar unsigned char
#define uint unsigned int
#define ds1302_rst PE4
#define ds1302_io PE3
#define ds1302_sclk PE2
#define set_ds1302_rst_ddr() DDRE|=1
#define set_ds1302_rst() PORTE|=1
#define clr_ds1302_rst() PORTE&=~(1
#define set_ds1302_io_ddr() DDRE|=1
#define set_ds1302_io() PORTE|=1
#define clr_ds1302_io() PORTE&=~(1
#define clr_ds1302_io_ddr() DDRE&=~(1
#define in_ds1302_io() PINE&(1
#define set_ds1302_sclk_ddr() DDRE|=1
#define set_ds1302_sclk() PORTE|=1
#define clr_ds1302_sclk() PORTE &=~(1
#define ds1302_sec_add 0x80
#define ds1302_min_add 0x82
#define ds1302_hr_add 0x84
#define ds1302_date_add 0x86
#define ds1302_month_add 0x88
#define ds1302_day_add 0x8a
#define ds1302_year_add 0x8c
#define ds1302_control_add 0x8e
#define ds1302_charger_add 0x90
#define ds1302_clkburst_add 0xbe
uchar TempData[8];
uchar timer[7]={12,2,8,20,31,50,3};
uchar WeiMa[8] = {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
uchar led_discode[11]={0xc0,0xf9,0xa4,0xb0,0x99,
void smg_io_init(void)
{
PORTA=0XFF;
DDRE=0xff;
DDRC=0XFF;
PORTC=0XFF;
DDRF|=0X0E;
PORTF|=0X0E;
PORTF&=0xF7;
DDRB |=0X10;
PORTB|=0X10;
}
void display(uchar FirstBit,uchar Num)
{
for(i=0;i
{
PORTC=led_discode[10];
Delayms(2);
}
}
void Delayms(uint MS)
{
} void shi_BCD(void) { for(i=0;i<7;i++) { timer[i]=timer[i]; timer[i]=timer[i]+k*16; } } void ds1302_init(void) { set_ds1302_rst_ddr(); set_ds1302_sclk_ddr(); clr_ds1302_rst(); } void ds1302_write(uchar add,uchar data) { set_ds1302_io_ddr(); add = add & 0xFE; } uchar ds1302_read(uchar add) { } void ds1302_write_time(void) {
AVR128DS1302时钟芯 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)