Weird problem. MAX7219 & Propeller
TC
Posts: 1,019
Hello all,
I have a weird one that I cannot figure out. I am trying to get a MAX7219 to work with the prop. It works. Somewhat.
I have an LED hooked to pin 23 just to show where in the program it is at. The MAX7219 only has 3 displays, and all of them count from 0-9 as fast as they can.
This is just the start of the program, and I need to find out why it is doing this so I can continue with it.
I have included my code.
What happens
1) I turn on the power supply
2) about 2 seconds the LED that is connected to pin 23 will light up
3) Then after about 18 20 seconds it will start counting and the LED will flash and work like it should
4) After about 30 32 seconds it will freeze. The displays will stop, stay on and show numbers, and the LED will be on or off ( like the prop stopped in the middle of doing something)
5) Then after 30 32 seconds it will start working again
One, I need to find out why it takes so long to go from lighting up the LED, and starting the display
and two, I need to find out why it will stop, when it should keep running forever.
Thanks
TC
I have a weird one that I cannot figure out. I am trying to get a MAX7219 to work with the prop. It works. Somewhat.
I have an LED hooked to pin 23 just to show where in the program it is at. The MAX7219 only has 3 displays, and all of them count from 0-9 as fast as they can.
This is just the start of the program, and I need to find out why it is doing this so I can continue with it.
I have included my code.
What happens
1) I turn on the power supply
2) about 2 seconds the LED that is connected to pin 23 will light up
3) Then after about 18 20 seconds it will start counting and the LED will flash and work like it should
4) After about 30 32 seconds it will freeze. The displays will stop, stay on and show numbers, and the LED will be on or off ( like the prop stopped in the middle of doing something)
5) Then after 30 32 seconds it will start working again
One, I need to find out why it takes so long to go from lighting up the LED, and starting the display
and two, I need to find out why it will stop, when it should keep running forever.
Thanks
TC
Comments
That said I do have some suggestions.
Add some delays. I wonder if there needs to be a bit of time between calls to the '7219 object.
What's your power supply like. Could the LEDs be causing a reset?
And finally the sure fire way to find you problem. Add debug statements. Lots of them.
When I'm having trouble with code I just have the program tell me which method it's in, what the values of variables are and so forth. Usually with enough information coming out of the program I can find where something isn't happening as expected.
Haven't read your code, but that sounds exactly like an issue with CNT rollover. Either you're occasionally waiting for a CNT value that's already passed, or you are doing something like "CNT_target > CNT" in the code. You should always calculate the difference between CNT and your CNT_target first before doing a comparison. (i.e use "(CNT_target - CNT) > 0" to avoid rollover issues.)
Marty
I will have to try adding some delay to it. But wouldnt the problem be there all the time? not at the start, and every 20 seconds?
I tried two power supplies, first one is a computer power supply where both the +5V, and +3.3V have there own ground. Then I tried my power supply that I have had for years that has never gave me any problems.
I did a debugging, and every time the PROP would stop, so would the debug. then continue with where it left off at.
That is why I am at a loss.
The only CNT i am using is a delay for clocking the data, and to load the MAX
I got the calculation from "SPI_spin.spin" ( Beau Schwabe (Parallax) ) I just took out the parts i didnt need. Im still trying to fully understand how the delay works, what would you recommend?
Ah, I had incorrectly assumed you got the object from the OBEX. Sorry. Since the driver is untested, there even more ways possible to mess it up.
No one has used the Prop with the '7219 (and shared the code)? That's surprising.
Mess it up?!?! I know I will mess it up, that is half the fun.
And I agree with you. A 7219 is a great chip, once I am done and it fully works, I am going to post it.
THAT DID IT!!!! Thank you very much.
Now I have a question, Why was that screwing it up? and is there a way for someone with very little knowledge of timing, to understand what is going on?
There's your problem, "+" is a higher priority operation than "#>" so it evaluates first. So that statement ends up being as. That does a limit minimum on a target CNT value. Half the time you'll be waiting for CNT to equal 381, hence the 32 second delay. i.e. when CNT is a two's-compliment negative number. CNT loops through all numbers between the POSX and NEGX constants.
Marty
Oh, now I get it!!! That makes sense now. Thank You