Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Interfacing 8051 to LED driver MAX7221

Status
Not open for further replies.

mikemania

New Member
Hi,

I am having some difficulties interfacing the 8051 to the MAX7221 driver chip using SPI. As I understand it, it receives a 16bit signal and that would require bit-banging as the 8051 only sends 8bits. I am having trouble understanding how to do this in the assembly language.

The uC is 8051f340 from SiLabs.

Thanks
 
This is the next tutorial in my 8051 series.... It's been on hold for a few weeks but I aim to get it back on track soon.

With SPI you can send a byte twice in succession to achieve 16 bit.. So.. Clear the CS bit load the SPI reg with the HIGH byte... Send...Load with the LOW byte... Send... Then Set the CS bit.... All done..

If you can send a byte, then you can send a double byte... The trick is to control the CS pin, so choose your own CS pin..
 
Thanks for the reply. I actually found this site after landing on your tutorials. As my luck would have it, you stopped right before the info I needed haha.

Here is a snippet of what I'm doing.

If I'm reading the MAX7221 datasheet correctly, I am sending the normal operation command first then display "5" on digit 1.

Nothing seems to show up. I am thinking it may be a configuration problem, specifically with SPI. Here's what I'm doing:
https://i.imgur.com/HbMy3H6.jpg

Code:
clr   SPIF
clr     CS
nop
;Send Normal Operation Command
mov   SPI0DAT, #0CH
jnb   SPIF,$
mov   SPI0DAT, #01H
jnb   SPIF,$
nop
setb  CS

 lcall delay2

clr     CS
nop
;Display #5 on Digit 1
mov   SPI0DAT, #01H
jnb   SPIF,$
mov   SPI0DAT, #5BH
jnb   SPIF,$
nop
setb  CS
nop
                       
lcall delay2
 
Alright, so with the following code and format, I was able to successfully talk to the 7221 chip. However, I am using 6 digits and the last 2 7-segments do not display what they should. They instead display a random symbols that do not seem to correlate to the intended value. I set the scan limit to the number of characters I'm using, and still the 5th and 6th are jumbled. Not sure if this is an 8051 issue anymore.

Code:
    clr    CS               ;SET CHIP-SELECT LOW
    nop
    mov   SPI0DAT, #0C0H    ;SHUTDOWN REGISTER
    jnb   TXBMT,$                    ;TRANSMIT BUFFER EMPTY
    mov   SPI0DAT, #010H    ;NORMAL OPERATION
    jnb   TXBMT,$
    nop
    setb  CS                            ;SET CS HIGH
    clr     SPIF                        ;CLEAR SPI INTERRUPT
    nop
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top