Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
11/04/04 20:45
Read: times


 
#80388 - AT89S8252 SPI problem
Hi all.
I need to interface two AT89S8252 by SPI port, one will be the master and the another one, the slave.
I need to transmit sixteen bytes from master to slave.
Master does not implement an interrupt but slave yes.
Master is sending the 16 bytes data packet about 10 times a second.
Slave shows in 8 LED the 1st data sent by the master.
I did it in assembler code, and it works, BUT......
after five or ten second's that the master begin to transmit data, the slave begins to show erratic data recieved.
If I put the "almost" same code in the slave, but without using a SPI interrupt, instead pooling it by a loop secuence, I have NO problems at all, and it works fine,... obviusly I need to have the SPI ISR at the final code of the project.
I CANT found any MASTER-SLAVE example code in assembler for AT89S8252 in web.
Some idea why the problem ?

The source code looks like this:

; Primary controls
$MOD8252
$PAGEWIDTH(132)
$DEBUG
$OBJECT
$NOPAGING
;
; Variable declarations
;
CANAL DATA 033H
VALOR DATA 034H
;
BUFFER BIT 020H
PASO BIT 021H
CERO BIT 022H
SPIF BIT 10000000B
;
CS EQU P1.4
;
ORG 00H
AJMP MAIN
ORG 23H
AJMP INTSPI
;
INTSPI: MOV A,SPSR
ANL A,#SPIF
JZ INTSPI
MOV CANAL,SPDR
JNB BUFFER,APECE
MOV R0,VALOR
MOV @R0,CANAL
INC VALOR
MOV A,VALOR
CJNE A,#06FH,GUIMO
MOV VALOR,#060H
CLR BUFFER
GUIMO: RETI
APECE: MOV P2,CANAL ;show P2 (leds)the 1st data
SETB BUFFER
RETI
;
MAIN:
SETB MISO
SETB MOSI
SETB SCK
SETB CS
MOV SPCR,#0E7H ;
MOV IE,#090H
MOV PCON,#00H
MOV VALOR,#060H
CLR BUFFER
MOV P2,#00H
CLR PASO
;
LUP: AJMP LUP
END


List of 8 messages in thread
TopicAuthorDate
AT89S8252 SPI problem            01/01/70 00:00      
   Try simplifying            01/01/70 00:00      
      RE: Try simplifying            01/01/70 00:00      
      RE: Try simplifying            01/01/70 00:00      
   RE: AT89S8252 SPI problem            01/01/70 00:00      
   RE: AT89S8252 SPI problem            01/01/70 00:00      
      handshake            01/01/70 00:00      
      RE: AT89S8252 SPI problem            01/01/70 00:00      

Back to Subject List