This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

SPDR not receiving data

Hi,

IÂ'm trying to use SPI in AT89S8252. Problem is that I canÂ't write to SPDR. SPDR doesnÂ't receive data but still software sets SPIF flag. Also I can write the 00h value of the SPDR to ie. R2.

code:

MOSI    EQU             P1.5
MISO    EQU             P1.6
SCK     EQU             P1.7
SS      EQU             P1.4

MOV P1,#0

MOV 0D5h,#00111000b  /* Sets DORD, MSTR, CPOL bits */
MOV 0D5h,#01111000b  /* Sets SPE bit */

MOV R1,#255

MOV 086h,R1       /* send an example data to SPDR*/

        NOP
        NOP             /*SPIF bit sets*/
        NOP
        NOP
        NOP
        NOP
        NOP

Is this a software bug or me, as a beginner, being incompetent!?

Please help me out!

Regards
Aki

Parents
  • In software I canÂ't write anything to SPDR. IÂ've initialized SPI registers as said in manual. With and without slave select. I DonÂ't know what is happening because I canÂ't write SPDR(according to peripherals ->SPI-window) but software sets SPIF after MOV SPDR,#255 order. I can read the dafault value(00h) from SPDR.IÂ'm assuming software is flawless so I havenÂ't seen any sense loading my code to 8252 and testing actual device in practice.

Reply
  • In software I canÂ't write anything to SPDR. IÂ've initialized SPI registers as said in manual. With and without slave select. I DonÂ't know what is happening because I canÂ't write SPDR(according to peripherals ->SPI-window) but software sets SPIF after MOV SPDR,#255 order. I can read the dafault value(00h) from SPDR.IÂ'm assuming software is flawless so I havenÂ't seen any sense loading my code to 8252 and testing actual device in practice.

Children
  • You are running in the simulator? If you run in the simulator, then you need to write a simulation script that handles the SPI interface and picks up the transmitted byte and sends back another byte.

    Without a simulation script, Keil can not simulate any SPI.

    I don't know how it is with the SPI simulation, but for UART simulation, Keil normally has a flag if the simulation should run in simulated time - delay based on baudrate - or performing instant transfers. Maybe Keil performs instant transfers for the SPI interface.