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.
There is a problem with your program and that is that the variable will overvlow since it is never reset to 0. Adding a 1 when you are at 255 will make the next count 0, but mplab perhaps doesn't know how to "resolve" this.
What results are you getting? I would be confident that your code should work, I am not sure how well mplab simulates a PBP code, since I have never done it
I would add a reset when cnt = 255, like this:
cnt var byte
If cnt = 255 then
Ivancho, are you refering to my code? I tried this in PIC simulator IDE, I have 0 experience with MPLAB.And it worked perfect(after I removed the "if" statement,that is).This should give the result he is looking for, not sure what he wants to do with the lower nibble on portb though.Also this assembles into 14 words, the other code is 33 words.
I didn't investigate too much, but it counted incorrectly with the "if" statement(never got to 1111).The original "if" statement was in the wrong place, it should have been before the"cnt=cnt+16".It worked correctly with the if statement in the right place,but it also worked correctly with no "if" statement at all(each count was 6 instruction cycles including 1111 and 0000).I see what you are saying, and I guess I never put much thought into how PBP rolls variables.I don't know much about mplab, I think I will have to learn.