Using MAX7221


Closed Thread
Results 1 to 12 of 12

Thread: Using MAX7221

  1. #1
    Join Date
    Apr 2005
    Location
    Virginia
    Posts
    65

    Default Using MAX7221

    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.

    Code:
    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.
    Attached Images Attached Images

  2. #2
    Join Date
    Nov 2007
    Location
    Lake Villa Il.
    Posts
    40


    Did you find this post helpful? Yes | No

    Smile Re max7221

    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

  3. #3
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    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.
    Last edited by aratti; - 11th January 2009 at 09:50.
    All progress began with an idea

  4. #4
    Join Date
    Apr 2005
    Location
    Virginia
    Posts
    65


    Did you find this post helpful? Yes | No

    Talking Eureka!

    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:

    Code:
    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!!!

  5. #5
    Join Date
    Apr 2005
    Location
    Virginia
    Posts
    65


    Did you find this post helpful? Yes | No

    Default One More Question

    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?
    Attached Images Attached Images  

  6. #6
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Tray to add a capacitor (electrolitic 220 uF 16V) at pin 19 of MAX7221 and see if it removes the problem.

    Al.
    All progress began with an idea

  7. #7
    Join Date
    Apr 2005
    Location
    Virginia
    Posts
    65


    Did you find this post helpful? Yes | No

    Unhappy

    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

  8. #8
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Just a little wiring problem.

    DIG0 and SEGD are connected.

    <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3108" /><!-- Name:  MAX7221_Wires.JPG
Views: 1745
Size:  49.7 KB -->
    DT

  9. #9
    Join Date
    Apr 2005
    Location
    Virginia
    Posts
    65


    Did you find this post helpful? Yes | No

    Thumbs up Doh!

    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

  10. #10
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    It was your very neat and organized breadboard that allowed me to find it.

    Something to be proud of.
    <br>
    DT

  11. #11
    Join Date
    Apr 2005
    Location
    Virginia
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    Darrel,

    Thank you! I do take great pride in my wiring. 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!

  12. #12
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by elec_mech View Post
    Thank you! I do take great pride in my wiring.
    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)

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

    CYA soon,
    DT

Similar Threads

  1. how can i shift between two max7221 with shiftout command
    By lutherblissett in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 9th December 2005, 15:50
  2. can i drive four max7221 with 3 lines only?
    By lutherblissett in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 24th November 2005, 18:16
  3. it's possible to drive four max7221 serially connected?
    By lutherblissett in forum General
    Replies: 0
    Last Post: - 23rd November 2005, 18:38
  4. max7221 cascade mode
    By lutherblissett in forum General
    Replies: 1
    Last Post: - 10th November 2005, 11:52

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts