??? 03/25/11 22:22 Read: times |
#181642 - Hardware SPI in AT89C51RD2 |
Hello Guys I have a bunch of ATMEL AT89C51RD2-CM date code 0306. I am trying to use the hardware SPI with no luck. According to the combined AT89C51RD2/AT89C51ED2 datasheet, this device has an SPI Interface.
The code below works on the AT89C51ED2, but not on the AT89C51RD2. In the code, I have simulated a CS line that goes low just before the SPI data is sent.I checked with a logic analyzer, there is no activity on any of the pins except the simulated CS line. I was wondering if the datasheet might be wrong? (After all, there ARE other mistakes in this datasheet!!) I am well aware that the older (Temic) T89C51RD2 devices do not have an SPI interface. I can always bit-bang the data but I was hoping to use the hardware interface. Anyone know whether or not the datasheet is wrong? I find it hard to believe that every single one of my AT89C51RD2's are defective. ;this code is working for the AT89C51ED2 but not the AT89C51RD2. mov SPCON,#10010110b ; Fclk Periph/128, Master Mode, SPI Mode 3 ; mov SPCON,#10110101b ; same as above except Fclk Periph/64 orl SPCON,#40h ; start spi mov r7,#0 ; start data @ 00h loop: mov SPI_Temp,r7 ; lcall SendSPI ; lcall Delay1mS inc r7 ;send 0h - 0FFh to SPI mov a,r7 jnz loop xrl SPCON,#40h ; disable spi stop: sjmp stop ; ;send SPI data from SPI_Temp, returns read SPI data in SPI_Temp SendSPI: clr P1.0 ;trigger for Logic Analyzer mov SPDAT,SPI_Temp ;transmit SPI Data WaitSPI: mov a,SPSTA jnb acc.7,WaitSPI ;wait for TX complete before reading mov SPI_Temp,SPDAT ;read SPI Data setb P1.0 ;trigger for Logic Analyzer ret |
Topic | Author | Date |
Hardware SPI in AT89C51RD2 | 01/01/70 00:00 | |
Hardware SPI in AT89C51RD2 | 01/01/70 00:00 | |
tried a few things | 01/01/70 00:00 | |
Temic marked as Atmel | 01/01/70 00:00 | |
thankyou Jan | 01/01/70 00:00 | |
signature bytes | 01/01/70 00:00 | |
signature | 01/01/70 00:00 | |
maybe![]() | 01/01/70 00:00 | |
Looks like mode #1 to me | 01/01/70 00:00 | |
header files | 01/01/70 00:00 | |
Spend the time to create proper header file | 01/01/70 00:00 | |
RE: i could never find the right header file | 01/01/70 00:00 |