PDA

View Full Version : Take it from a big dummy - CHECK YOUR SPECIAL REGISTER SETTINGS!



andywpg
- 8th March 2013, 01:17
Ok, wow, do I feel stupid now.

About 10 or so days ago, I posted THIS THREAD (http://www.picbasic.co.uk/forum/showthread.php?t=17742) because I was beating my head against the wall trying to get an interrupt to work.

Since then, every evening, I have tried something else, and tonight, I finally got it.

All along, I was using PORTB.0 to trigger part of the program - I had PORTB defined as all digital. I had PORTB.0 defined as an input. I turned on PORTB change of state interrupt, I enabled the interrupt on PORTB.0. I turned on the weak pullup for PORTB.0. But in the OPTION register, I specifically was TURNING OFF PORTB PULLUPS!

I didn't look at the datasheet "because I've done this a bunch of times - OPTION.7 = 1 is PORTB pullups on"

:eek: AAGGGHHHH! OPTION.7 = 1 is pullups OFF! No wonder it wasn't working!

So, I guess the moral of the story is, if you're sure it should work, go over those darned special function register settings again, and save yourself a headache

<RANT MODE OFF>

rmteo
- 8th March 2013, 09:29
When working with microcontrollers, an intimate knowledge of the hardware is absolutely essential (know the entire data sheet and/or user/reference manuals like the back of your hand) to get the most out of it. If you have that, then you can work with just about any microcontroller (and development system) to get the most effective solution to the project at hand. Without it, however, no software development system will help (no matter how good or how easy it is to use) as you have found out.