I have spent the past day(i know it sounds stupid) figuring out how to make a 1sec delay on the PIC16F690 to make an led blink. hope you guys can help.
your program is hard to read your program is hard to read since it is missing some spaces in multiple places. please fix these so we can better see what is wrong
Since Timer0 is set to 8-bit timer mode, it increments by 1 for each instruction cycle, except for the first 2 cycles after clearing it. The ‘end condition’ you’re waiting for is when Timer0 == 32, but what about if Timer0 is increasing too fast and it goes higher than 32? When that is the case, SUBLW will not set the Zero bit on the Status register, and therefore the end condition will not trigger as expected.
Instead of using the Zero bit in “BTFSS STATUS,ZEROBIT”, try using “BTFSC STATUS,C” where C is the Carry bit in the Status register. If Timer0 is > 31 (ie: Timer0 >= 32), the Carry bit will be 1, which means the end condition will still trigger even if Timer0 is already slightly larger than 32 by the time SUBLW is computed.
There are no operators in ASM, so your “=>” won’t work. The format is always label/mnemonic/argument(s). The replacement code I was thinking of would go like this:
get a new PIC Most of the PIC’s In the 18FXX series have a comparitor. since the cips are relitively inexpensive I recommend getting a new one with more features. you get to do things like skip on equal or lessthan or greaterthan. It will make your programs easier to read and quicker to write.
Although they make Although they make programming more convenient they don’t add any new functionality; in the end the ‘new’ conditional branches are still testing the status bits in the same way.
Just as a suggestion, I will share one of my favoirte quotes from the preface of one of my favorite PIC books: The PIC Microcontroller: Your Personal Introductory Course.
“I am happy to help, and will try to answer any questions you may have. However, I have also been sent PIC programs without a single comment on them, and often without any indication of what task they they are actually meant to perform, with a short message along the lines of: ‘It doesn’t work.’” … “These types of [inquiries] will seldom meet with a favorable response, simply because I haven’t a clue what to do. So please put comments everywhere in your programs and try to isolate exactly what is going wrong”
Is there mode code than what Is there mode code than what you’ve given us here? If not, then you haven’t set any of the configuration bits. Depending on your programmer you can either set the config bits in the code or have the programmer set them for you; I suggest you do some reading on the config bits, they’re quite important.