This line is wrong.
Should be.lcdout "Count = ",# counter 'display count value
Might cause the program to hang?Code:lcdout $FE,"Count = ",# counter 'display count value
This line is wrong.
Should be.lcdout "Count = ",# counter 'display count value
Might cause the program to hang?Code:lcdout $FE,"Count = ",# counter 'display count value
Dave
Always wear safety glasses while programming.
Thanks for the correction. I was hoping that was the culprit but it has not corrected the problem. Strange!!
Thanks again
Hello Wildbilly,
Data sheet says Port B 4-7, interrupt on change. Port B0
should interrupt when taken low assuming pullups on ( I think).
Even though data sheet says POR and BOR TrisB will reset as 11111111
I think I would add tris statement early in code to advise PIC it is an input.
Have you tried interrupt on any of ports b 4-7 ?
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
I just tested you code and every time PORTB.0 is connected to 0 volts(ground) the LED blinks and the LCD counts.
Here is what I have with a couple small changes. Look at comments.
Code:DEFINE OSC 20 Define LCD_DREG PORTD Define LCD_DBIT 4 Define LCD_RSREG PORTD Define LCD_RSBIT 2 Define LCD_EREG PORTD Define LCD_EBIT 3 DEFINE LCD_LINES 2 'Number lines on LCD TRISB.0 = 1 led var PORTB.5 'CHANGED BECAUSE ICSP counter var byte OPTION_REG = %01111111 'Enable portb pullups and 'rising edge on B0 interrupt On interrupt goto myint 'Define interrupt handler INTCON = %10010000 'Enable INTE interrupt counter = 0 '**** Main Loop *** loop: lcdout $fe,1 'CLEAR SCREEN lcdout "Count=",# counter 'display count value pause 50 'TIME TO DISPLAY high led 'turn led on goto loop 'Do it forever '*****Interrupt Handler ***** Disable 'No interrupts pass this point myint: low led 'if we get here turn led off Pause 300 'wait .3 seconds counter = counter + 1 INTCON.1 = 0 'clear interrupt flag resume 'return to main program enable end
Dave
Always wear safety glasses while programming.
Hi Dave thanks for your help. I have tried your suggestions and still have the same problem. I even copied your code directly and still no fix. You said you have it counting. I can only get it to count to one and then it stops. You said when you pushed the button to ground, it would count. Did you have it counting pass one? Another thing is the Option_Reg bit 6 is set for "Rising edge". You said you pushed the button low. It should not work if the bit is set for rising edge.
I guess I should also disclose that I am using the "EasyPic4 Development Board". I wonder if that is my problem.
If you want it to interrupt when RB0 goes high, comment out the OPTION_REG line and use external resistor from RB0 to ground.
With the OPTION_REG set as you have it "pull-up""set" the pin will need to go LOW to trigger the interrupt. No external resistor.
From data sheet.
I counted to 255 then of course it rolls back to 0 and starts over.External interrupt on the RB0/INT pin is edge triggered,
either rising, if bit INTEDG (OPTION_REG<6>) is set,
or falling, if the INTEDG bit is clear.
Not sure, never used the "EasyPic".I guess I should also disclose that I am using the "EasyPic4 Development Board". I wonder if that is my problem.
I am using Ubuntu (linux) for an OS, running MPLAB with PBP as the language set via Wine hooked to a PICSTART PLUS rigged as an ICSP.
Dave
Always wear safety glasses while programming.
Thank for you suggestion JOE.S I will have to try the other Inputs as well, 4-7. Thank you to mackrackit. I have found the problem. There is a jumper on the board that was set for "Pull down" and I had the "Pull up" set in Option_Reg. They were fighting each other. I disabled the Option_Reg and it works very well. Thanks very much for your input. All that you said was spot on.
This is fun.
Wildbilly.
Bookmarks