Does anyone have a working simulation script for a SPI based device on the STR73x or similar CPU? I have tried multiple eeprom examples from other chips without success in receiving bytes. I have been unable to find any examples targeted toward the STR73x chip and simulator documentation is minimal on this particular flavor of SPI.
The SPI eeprom examples send information out to the SPI0_OUT register however writes to SPI0_IN never get reported back to the receive buffer.
Running on the real silicon reports a "0" receeved by the CPU if I do not connect the MOSI to MISO and it reports the outgoing byte if I connect the send to receive wires.
So, Any idea what has to be done to get the simulator scripts to send data back to the BSPI module and for the module to recieve and put in rx buffer?
Thanks, Chad
The simulation script:
// AT25 SPI Signal Function signal void AT25_SPI (void) { unsigned int uiWord; while (1) { twatch (0.00001); wwatch (SPI0_OUT); SPI0_IN =SPI0_OUT; printf("\n Got Byte %x",SPI0_IN); } }
The SPI init:
void SPI_Init( void ) { BSPI_InitTypeDef BSPI_InitStructure; /* enable GPIO clock */ CFG_PeripheralClockConfig( CFG_CLK_GPIO6, ENABLE ); /* enable BSPI0 clock */ CFG_PeripheralClockConfig( CFG_CLK_BSPI0, ENABLE ); /* Set CPU /SS high */ GPIO_BitWrite( GPIO6, GPIO_PIN_14, High ); // set eeprom /ss high SPI_SS( High ); /* BSPI0 configuration */ BSPI_InitStructure.BSPI_RxFifoSize = 10; BSPI_InitStructure.BSPI_TxFifoSize = 10; BSPI_InitStructure.BSPI_SSPin = BSPI_SSPin_Masked; BSPI_InitStructure.BSPI_CLKDivider = 6; BSPI_InitStructure.BSPI_CPOL = BSPI_CPOL_High; BSPI_InitStructure.BSPI_CPHA = BSPI_CPHA_1Edge; BSPI_InitStructure.BSPI_WordLength = BSPI_WordLength_8b; BSPI_InitStructure.BSPI_Mode = BSPI_Mode_Master; BSPI_DeInit( BSPI0 ); BSPI_Init( BSPI0, &BSPI_InitStructure ); BSPI_Cmd( BSPI0, ENABLE ); }
and the init call and test routine:
void Init_SPI0( void ) { // CFG_PeripheralClockConfig( CFG_CLK_BSPI0, ENABLE ); // BSPI_EE_ChipSelect( Low ); unsigned long testlong; unsigned char sendbyte; SPI_Init( ); sendbyte = 0xff; while( 1 ) { while( BSPI_FlagStatus( BSPI0, BSPI_FLAG_TFE ) == 0 ) ; BSPI_WordSend( BSPI0, sendbyte-- ); if( sendbyte == 0 ) printf( "\n\r Reset Byte to 0xff" ); if( BSPI_FlagStatus( BSPI0, BSPI_FLAG_RFNE ) ) { input_byte = BSPI_WordReceive( BSPI0 ); printf( "\n\r Got a Byte %x", input_byte ); } testlong = 100000; while( --testlong ) ; } }