Forum Discussion
Altera_Forum
Honored Contributor
14 years agoHello,
First of all, many thanks for your reply Daixiwen and I am sorry for my delay to answer. I have got an oscilloscope and could see the spi signals. The mistake must make in this reception part of my code. This part is:
// last byte of spi memory address
// wait to transmit
wdata=0xf0;
while ((iord_altera_avalon_spi_status(spi_base) & altera_avalon_spi_status_trdy_msk)==0);
// send data
iowr_altera_avalon_spi_txdata(spi_base,wdata);
////////////// wait the end of transmission //////////////
while ((iord_altera_avalon_spi_status(spi_base) & altera_avalon_spi_status_tmt_msk)==0);
// wait to receive
while ((iord_altera_avalon_spi_status(spi_base) & altera_avalon_spi_status_rrdy_msk)==0);
// clean data
iord_altera_avalon_spi_rxdata(spi_base);
iowr_altera_avalon_spi_status(spi_base,0x00);
////// dummy bite to read the spi memory ifnormation
// wait to transmit
wdata=0x00;
while ((iord_altera_avalon_spi_status(spi_base) & altera_avalon_spi_status_trdy_msk)==0);
// send data
iowr_altera_avalon_spi_txdata(spi_base,wdata);
// wait the end of transmission
while ((iord_altera_avalon_spi_status(spi_base) & altera_avalon_spi_status_tmt_msk)==0);
// wait to receive
while ((iord_altera_avalon_spi_status(spi_base) & altera_avalon_spi_status_rrdy_msk)==0);
// read data
led_val=iord_altera_avalon_spi_rxdata(spi_base);
iowr_altera_avalon_spi_status(spi_base,0x00);
//disable cs
iowr_altera_avalon_spi_control(spi_base,~altera_avalon_spi_control_sso_msk);
usleep(25);
// display data
iowr_altera_avalon_pio_data(led_base,led_val);
The problem is when I send to the spi memory the last byte of the address which I want to read (emphasized in bold). The MOSI signal appears in the oscilloscopi such as I expected. By contrast, the MISO signal is not working when the spi memory, in principle, is sending the data of the desired address (0x0000F0). I have already checked the hardware connection several time, so I think the mistake must be by software. I would be very grateful if anyone could give a piece of advice about my problem. Many thanks,