We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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
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.