AVR的SPI驱动74HC595测试程序点击: 69, 文章入库日期: 2008-05-29 07:49:39, 来源: www.picavr.com
#include<avr/io.h>#define uchar unsigned char#define uint unsigned int#define lat_on PORTB|=0x10#define lat_off PORTB&=0xe0void spi_init(void) { SPCR=0x70; SPSR=0X01; } void spi_send(uchar dd) { SPDR=dd; while(0==(SPSR&0X80)); }int main(void) { DDRB=0xff; PORTB=0XFF; spi_init(); lat_off; spi_send(0x92); spi_send(0x24); lat_on; while(1);