Thanks, I think it's the compiler, the AD program was fine on yours, yet it didn't register on mine. Now this definitely seem to indicate a problem with either the compiler or the programmer.
Thanks, I think it's the compiler, the AD program was fine on yours, yet it didn't register on mine. Now this definitely seem to indicate a problem with either the compiler or the programmer.
I use the exact same assembler as you (MPASM in MPLAB). Same programmer too, I think (PICkit 2 or Junebug?), not that that would make any difference.
Do you assemble the program and reprogram the chip in debug mode from the Debugger menu before stepping through it? If you don't, it won't work properly.
I put the switch to tutor, then assemble the program, then establish contact, then download the program. Then go into debugger, start "animation" start "view" special function registries, the registries vary when it goes through the animation, STATUS, and ADCON0 toggle the GO bit...
OK I restarted MPLAB, and now the PORTB toggles... but the LEDs don't light up.
OK the LEDS are on PortA, so I changed it, and it still doesn't light up.
Baby steps are frustrating... and the registry doesn't change either.
From the debugger menu.... NO I assemble from the top of the page.
You understand that the Firefly's LEDs are charlieplexed, right? They won't work properly if you don't understand that part. Look closely at the schematic. RA0, RA6 and RA7 as well as their TRIS bits must be toggled correctly to get the LEDs you want lit up.
Same as before... with a different delay routine.
I put a 2 tocks delay in the routine so it goes through the debugger quickly. For a 1 second delay it's 200 tocks in both timers.
Your problem was that you forgot to configure your PortA pins as all digital. Add this while you're switched to bank 1:
Code:
clrf ANSEL
Bit-5 still isn't switching. I have to refresh my foggy memory on why exactly. But your main problem was forgetting that on reset all PortA bits are configured as analog by default.
EDIT: Well duh! Bit-5 is MCLR. As long as the debugger is in control, that can't be played with.
Everybody goes through this stage where everything is confusing. And it always seems like it must be the tools at fault. It isn't. It's you. It really is! MPLAB is remarkably bug free. There are some, but you haven't seen them yet.
Keep at it and you'll be up to speed in no time. And all this confusion will disappear. Then you can finally get some cool things done.
You learned some good lessons today though... Practice, practice, practice. It gets easier with more practice. You can only learn to program by writing programs. Lots and lots of programs! Even if they're crap, you need to practice to get better at it. Reading books won't help unless you write tons of programs while reading.
I think I have to set ANSEL correctly for AD to work... !
ANSEL 00001000
Yes, I know it's me... I have to keep plugging at it, and I can only thank you for your patience futz, I do need someone to help me through my baby steps. ANd that's why I write these baby step programs like flashing a LED and turning on registers. I intend to do a lot of cool things with this newfound hobby, maybe even quit trucking and get into this as a way to make money. I do have a couple of projects to do and customers waiting for me to deliver, so I have no choice but to forge ahead.