您好,这个我写的初始化函数和代码,我在主函数while(1)里面一直调用 spi发送函数,用示波器看不到clk信号和数据,不知道问题出在哪里?
void C6747_SPI_init ( )
[
//配置spi0的 cs clk mosi 为相应的功能引脚
PINMUX7 = 0x18111888; // EMIFB, 1.SPI0/CS P54 /2.SPIEN,P53/3.SPICLK PIN52 /4.SPISIMO PIN51
//1. Reset the SPI by clearing the RESET bit in the SPI global control register 0 (SPIGCR0) to 0.
SPI0_SPIGCR0 =0x00;
DELAY_US1(1000);
// 2. Take the SPI out of reset by setting SPIGCR0.RESET to 1.
SPI0_SPIGCR0 =0x01;
SPI0_SPIGCR1 =0
|(0<<24)
|(1<< 16)
|(1<<1)
|(1<<0);
SPI0_SPIPC0 =0
| (1<<11) //DI
| (1<<10) //DO
| (1<<9) //CLK
| (1<<1) //EHI
| (1<<0) ; //EH0
SPI0_SPIPC1 =0
| (1<<11)
| (0<<10)
| (1<<9)
| (1<<0); // SPIx_SCS[n]管脚方向为输出.
spidat1= 0
| (1 << 28)// The chip select signal is held active
| (0<< 24)
| (2<< 16)
| (0 << 0) ;
SPI0_SPIDAT1 =spidat1;
SPI0_SPIFMT0 = 0
| (0 << 20)
| (0 << 17)
| (1 << 16) // SPI clock delay.
| (4 << 8) // SPI clock frequency = SPI module clock/(PRESCALE + 1)
| 8; // SPI data word length.
SPI0_SPIDELAY =0
|(8<<24)
|(8<<16);
SPI0_SPIDEF =0
|(1<<1)
|(1<<0);
SPI0_SPILVL =0
|(0 <<8)
|(0<<6)
|(0<<4);
SPI0_SPIGCR1 |= (1 << 24); // SPI enable.
]
void C6747_SPI_write_read ( Uint8 data )
[
while( (SPI0_SPIBUF & 0x1000000) ); // 0<<29 发射寄存器空, 1<<28 位发射错误
SPI0_SPIDAT1 |= data;
]
您好,这个我写的初始化函数和代码,我在主函数while(1)里面一直调用 spi发送函数,用示波器看不到clk信号和数据,不知道问题出在哪里?
void C6747_SPI_init ( )
[
//配置spi0的 cs clk mosi 为相应的功能引脚
PINMUX7 = 0x18111888; // EMIFB, 1.SPI0/CS P54 /2.SPIEN,P53/3.SPICLK PIN52 /4.SPISIMO PIN51
//1. Reset the SPI by clearing the RESET bit in the SPI global control register 0 (SPIGCR0) to 0.
SPI0_SPIGCR0 =0x00;
DELAY_US1(1000);
// 2. Take the SPI out of reset by setting SPIGCR0.RESET to 1.
SPI0_SPIGCR0 =0x01;
SPI0_SPIGCR1 =0
|(0<<24)
|(1<< 16)
|(1<<1)
|(1<<0);
SPI0_SPIPC0 =0
| (1<<11) //DI
| (1<<10) //DO
| (1<<9) //CLK
| (1<<1) //EHI
| (1<<0) ; //EH0
SPI0_SPIPC1 =0
| (1<<11)
| (0<<10)
| (1<<9)
| (1<<0); // SPIx_SCS[n]管脚方向为输出.
spidat1= 0
| (1 << 28)// The chip select signal is held active
| (0<< 24)
| (2<< 16)
| (0 << 0) ;
SPI0_SPIDAT1 =spidat1;
SPI0_SPIFMT0 = 0
| (0 << 20)
| (0 << 17)
| (1 << 16) // SPI clock delay.
| (4 << 8) // SPI clock frequency = SPI module clock/(PRESCALE + 1)
| 8; // SPI data word length.
SPI0_SPIDELAY =0
|(8<<24)
|(8<<16);
SPI0_SPIDEF =0
|(1<<1)
|(1<<0);
SPI0_SPILVL =0
|(0 <<8)
|(0<<6)
|(0<<4);
SPI0_SPIGCR1 |= (1 << 24); // SPI enable.
]
void C6747_SPI_write_read ( Uint8 data )
[
while( (SPI0_SPIBUF & 0x1000000) ); // 0<<29 发射寄存器空, 1<<28 位发射错误
SPI0_SPIDAT1 |= data;
]
举报