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.

Counter Wont Count past 7

Status
Not open for further replies.

Overclocked

Member
ADD: Code Works, was a hardware mistake

Code:
Device = 18F1320
Clock = 4 // 4MHz clock
Config OSC = INTIO2, WDT = OFF, LVP = OFF
//includes go here

//Vars Go Here

Dim Digit As PORTA

TRISA = 0

OSCCON = $62            // select 4MHz internal clock
ADCON1  = $7f           //all digital
//program start

While True

For Digit = 0 to 9
      
       Select Digit
       Case 0
	   		 Digit =%0000
	    Case 1			
	   		 Digit = %0001 
	    Case 2			
			 Digit = %0010
	    Case 3			
	   		 Digit = %0011
	    Case 4			
	   		 Digit = %0100
	    Case 5			
	   		 Digit = %0101
	    Case 6			
   			 Digit = %0110
	    Case 7			
 			 Digit = %0111
	    Case 8			
			 Digit = %1000
	    Case 9			
 			 Digit = %1001		 
	EndSelect 
	delayms (1000)
Next	
	
Wend  
     
End

It will display 8 or 9 If I manually set digit to 8 or 9, But It wont count past those two numbers. It will Count up to seven and just skip those two numbers. Everything is hooked up properly, since Ive tested each individual digit and they all light up. Im using 4 LEDs as my output indicator.
 
Last edited:
Is the supply properly decoupled. The 8 draws the most current and may be rebooting the PIC.

Just tried adding a small value cap across the supply, but to no avail. Im using the 5V off of the junebug.

ADD: Im a total idiot. Epic Fail on my part, There was a short across the current limiting resistor for that LED. It was a jumper that was in there [that I didnt see] from something else.
 
Last edited:
does it take the right amount of time for 8 and 9 or does it go straight from 7 to 0?

Note that 8 and 9 have bit 3 set so maybe the corresponding pin is not connected.
 
Where does the term "Epic Fail" come from :) I've heard it before.

Wikipedia has Some info, but as to where it came from I dont know. I guess you could say its a funnier version of when Murphy's Law applies to something. Given my situation I assumed my code wasnt working when it was something Simple, hence Epic Fail.

If It was a regular Fail, My code Wouldnt have worked and the Jumper wouldnt have been there. Epic Fails dont happen often either.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top