新會員
Joined
: 2006/3/2 10:49 最後登入時間
: 2007/10/6 12:39
Group:
註冊會員
Level : 2 HP : 0 / 25 MP : 3 / 1357 EXP : 0
|
我现在用6014A,我在调试SPI时发现一个现象, 我用SPI读外部FLASH,外部FLASH中我已经写入数据,内容为:1,2,3,4,5,6,7,8....顺序值. 如果我把初始化I/O放在SPI的SPI2CON寄存器初始化之前,则读出的数据为1,3,5,7... 如果我把初始化I/O放在SPI的SPI2CON寄存器初始化之后,则读出的数据正常,为1,2,3,4,5... 请问这是为什么,是否初始化I/O有什么顺序问题 谢谢 源程序如下: //根据输入的片号选择FLASH芯片 //numb数据存储器FLASH芯片号 #define PORTDd PORTD void selectFlashChip(uchar numb) { switch(numb) { case 0: { PORTDd &= 0xff8f; PORTDd |=0x0020; PORTDd =PORTDd; };break; case 1: { PORTDd &= 0xff8f; PORTDd |=0x0030; PORTDd =PORTDd; };break; case 2: { PORTDd &= 0xff8f; PORTDd |=0x0040; PORTDd =PORTDd; };break; case 3: { PORTDd &= 0xff8f; PORTDd |=0x0050; PORTDd =PORTDd; };break; default: { PORTDd &= 0xff8f; PORTDd =PORTDd; //proDealError(selectChipError,0); } } } void main() { .... //selectFlashChip(0); 放在这里,则读出的数据是1,3,5,7,9... setupSPI2model(); //设置SPI工作模式 selectSPI2baud(1); //设置SPI波特率 useSPI2('Y'); //使能SPI selectFlashChip(0); //放在这里,则能正常读出数据1,2,3,4... //该语句必须放在setupSPI2model(); //selectSPI2baud(1); useSPI2('Y'); 的后面 readMemoryLine(xp,0x00000020,buff2,528); .... }
發表於: 2006/5/30 12:26
|