PDA

View Full Version : Using MAX7221



elec_mech
- 10th January 2009, 21:17
Hello Ladies & Gents,

I'm attempting to make a countdown timer using eight seven-segment digits controlled by a MAX7221. Upon initial breadboarding I got it to work. However, I decided to change some wiring to have the digit order better agree with the software and it hasn't worked since. At one point I accidently hooked up the current limiting resistor to the MAX7221 to the Vcc line. I've replaced the MAX7221 with a new one. I bought new breadboards and build a new circuit from scratch, also without luck. I'm blinking an LED to indicate when the program starts and stops and that works fine, so the program is running. I've also tried placing LEDs on the data, clock and enable lines to check the I/O pins and they work fine. I noticed in a previous topic that the there may be noise and added 10uF and 0.1uF capacitors - still no luck. I've included the code and a schematic of what I've build.



PORTA = $00 ' Set all port a pins low
PORTC = $00 ' Set all port c pins low
define OSC 4 ' Tell the program the oscillator is running at 4 MHz
TRISA = %11111111 ' Make all port A pins inputs
TRISC = %11100000 ' Make port C pins 4 & 5 inputs and the rest outputs
PORTA = $00 ' Set all port a pins to low
PORTC = $00 ' Set all port c pins to low
CMCON.0 = 1 ' Turn off comparator module
CMCON.1 = 1 ' Turn off comparator module
CMCON.2 = 1 ' Turn off comparator module
ADCON0.6 = 0 ' Use VDD as analog reference
ANSEL = %00001000 ' Use AN3 as analog input and set all other analog
' inputs to digital pins

CS_Max VAR PORTC.3 ' Chip select for MAX7221 IC
CS_DS VAR PORTC.2 ' Chip select for DS1302 IC
SPI_CLK VAR PORTC.0 ' Clock for SPI communication
SPI_SDO VAR PORTC.1 ' Serial Data Out for SPI communication
Tog_Switch VAR PORTA.1 ' Toggle switch
Sel_Switch VAR PORTA.2 ' Select switch

b1 VAR byte ' Button variable for toggle switch
b2 VAR byte ' Button variable for select switch

'************************************************* **********************************************
HIGH CS_Max
pause 500 ' Wait for 500ms

Main:

HIGH PORTC.4
PAUSE 500
LOW PORTC.4
PAUSE 500

LOW CS_Max ' Enable the MAX7221 to receive data
SHIFTOUT SPI_SDO, SPI_CLK, 1, [$0F01\16] ' Turn on Display Test (light up all LEDs on all eight digits)
HIGH CS_Max ' Pull chip select to MAX7221 high to act on transmitted data

PAUSE 5000 ' Wait one second

LOW CS_Max ' Enable the MAX7221 to receive data
SHIFTOUT SPI_SDO, SPI_CLK, 1, [$0F00\16] ' Turn off Display Test
HIGH CS_Max ' Pull chip select to MAX7221 high to act on transmitted data

PAUSE 1000 ' Wait one second

HIGH PORTC.4
PAUSE 500 ' Wait one second
LOW PORTC.4
PAUSE 500
END ' End Program


I do not have the DS1302, buttons or photoresistor connected yet as I'm stuck trying to get the MAX7221 to work. Outside of ESD problems or gremlins, I'm stuck. Any advice is greatly appreciated.

Sneaky-geek
- 11th January 2009, 03:38
Hello elec mech,

At first glance I think that your TRISC declaration may have a small problem, you have
TRISC = %11100000 ' Make port C pins 4 & 5 inputs and the rest outputs
Try changing this line above to
TRISC = %00110000 'This makes Bits 5, 4 as inputs

Do not feel bad, this is a common easy to make typo mistake.

I have learned, if it don't work, I am most likely the cause of the problem. I go back and re-read my remarks to see where I goofed.

Have a great day,
Sneaky-geek

aratti
- 11th January 2009, 09:42
From your schematic Iset is pulled down to ground with a 17K resistor.
If I remember correctly, Iset should be pulled up.

Another thing, your pic has the reset pin floating

Al.

elec_mech
- 11th January 2009, 16:36
Sneaky-geek,

Thank you for pointing out the inconsistency in the TRISC. It didn't affect the program as I had written it, but I should have corrected that when I changed it. It now reads:



TRISC = %11110000 ' Make port C pins 0-3 outputs and the rest inputs


Yes, I agree, most problems in embedded projects are self-inflicted, although never intentional. Having another pair of eyes to look at the problem has always helped me.

Aratti,

Thank you! I doubled-checked the pinouts from the Maxim datasheet this morning but I can't believe I goofed on the Iset resistor to Vcc. Ugh! That fixed my problem. I did add a 10k resistor to MCLR to Vcc when I moved everything to the second breadboard, but forgot to update the schematic. Thank you for looking that over.

Thank you both immensely for your advice and suggestions!!!

elec_mech
- 11th January 2009, 18:25
After the goof with the Iset resistor, all of the segments came on in test mode except the 'd' segment of right-most digit. I thought I could figure it out or Google it, but no luck. I've tried changing out the MAX7221 IC and swapped the two four-digit LED displays I'm using. The segment lights up if I power it independently, but the two MAX7221 chips I tried won't. This digit is the farthest from the MAX and I tried adding an additional jumper wire at one point to reduce resistance, but to no avail. The datasheet mentions wiring inductance and EMI, but I'm not sure how to limit that on a breadboard. I've included a picture. Any suggestions?

aratti
- 11th January 2009, 22:38
Tray to add a capacitor (electrolitic 220 uF 16V) at pin 19 of MAX7221 and see if it removes the problem.

Al.

elec_mech
- 12th January 2009, 21:59
Aratti,

I have a 10uF cap on there now, but I went ahead and tried the 220uF - still no luck. I'm wondering since it is occurring on the last digit if a bit from the PIC to the MAX7221 is getting lost somewhere. I tried connecting a 0.1uF and a 10uF cap, at separate times, to the DIN pin on the MAX7221, but no luck there either. Anything else that might cause the d segment on the last digit not to light up? Thanks for all the help thus far.


-Tony

Darrel Taylor
- 12th January 2009, 22:38
Just a little wiring problem.

DIG0 and SEGD are connected.

<img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3108" /><!-- 3108 -->

elec_mech
- 12th January 2009, 22:53
Darrel,

You made my day! Thank you! I troubleshot the heck out of the first breadboard I used so I didn't think to check for shorts on this one. Thanks again!!!


-Tony

Darrel Taylor
- 13th January 2009, 02:10
It was your very neat and organized breadboard that allowed me to find it.

Something to be proud of.
<br>

elec_mech
- 13th January 2009, 19:04
Darrel,

Thank you! I do take great pride in my wiring. :D I hope at some point in the future to try out your Instant Interrupts routine, as I read they're all the rage. Thanks again for your help!

Darrel Taylor
- 14th January 2009, 05:48
Thank you! I do take great pride in my wiring. :D
A very good trait, that we may have in common. :)
http://www.picbasic.co.uk/forum/album.php?albumid=1


I hope at some point in the future to try out your Instant Interrupts routine, as I read they're all the rage.
Oh yes, apparently "rage" is part of it. (wasn't intentional) :o

However, when you do, I'll try to smooth out the bumps.

CYA soon,