SPI主机程序
0赞
发表于 1/11/2012 5:55:29 PM
阅读(3327)
#includevoid IRQ_Handler(void) __irq; // IRQ Funtion Prototype int i = 0; int main(void) { GP4DAT = 0x04000000; // P4.2 configured as an output. LED is turned on IRQEN = SPI_MASTER_BIT; GP1CON = 0x22220000; // configure SPI on SPM SPIDIV = 0xCC; // set SPI clock 40960000/(2x(1+SPIDIV)) // 0xCC = 100kHz SPICON = 0x104B; // enable SPI master in continuous transfer mode // slave select will stay low during the all transmission while (1){ } } void IRQ_Handler() __irq { GP4DAT ^= 0x00040000; // Complement P4.2 if ((IRQSTA & SPI_MASTER_BIT) != 0) { SPITX = i; i++; if (i==30) IRQCLR = SPI_MASTER_BIT; } return ; }
