View previous topic :: View next topic |
Author |
Message |
Riddick
Joined: 09 Oct 2007 Posts: 9
|
RB Interrupt seems to be called even when disabled.. |
Posted: Tue Oct 09, 2007 6:11 pm |
|
|
Hi, as the title suggests I'm experiencing a problem with the RB interrupt service being called when I have explicitly disabled all interrupts.
The device is a Pic16F877A
Compiler version is: 3.249, using the MPLAB IDE.
Osc is 20MHz crystal.
I can post the code, but its 18 printed pages worth.
The circuit itself has a matrix of 24 LEDs, 8 pushbuttons and 8 inputs connected to toggle switches for testing. The final inputs will be N.C. Reed switches.
The device runs fine until I start changing the toggle switches on the inputs, which as it happens are connected to Port B. It is also only the RB4-7 inputs that cause the problem. The RB0-3 inputs don't have any effect other than the desired function.
As you can see from the code below, I have dummied up an ISR for the RB interrupt which illuminates a single led for 1 second. Quite often after this happens, the device appears to reset. I have another similar routine that illuminates a single (different) LED when the program starts. It's as if the return on the ISR is being ignored.
I'm at a complete loss as to what could be causing this. It's possibly something I've overlooked, but it's extremely frustrating and the deadline for this project is getting closer. Any suggestions would be greatly appreciated.
Code: | #fuses HS, NOPUT, NOPROTECT, NOWDT, NOLVP, NODEBUG, NOCPD, BROWNOUT
...
#INT_RB
void RB_isr(){
delay_ms(1000);
output_high(LEDR1);
output_low(LEDC3);
delay_ms(1000);
output_float(LEDR1);
output_float(LEDC3);
delay_ms(2000);
return;
}
void main(void){
disable_interrupts(INT_RTCC);
disable_interrupts(INT_RB);
disable_interrupts(INT_EXT);
disable_interrupts(INT_AD);
disable_interrupts(INT_TBE);
disable_interrupts(INT_RDA);
disable_interrupts(INT_TIMER0);
disable_interrupts(INT_TIMER1);
disable_interrupts(INT_TIMER2);
disable_interrupts(INT_CCP1);
disable_interrupts(INT_CCP2);
disable_interrupts(INT_SSP);
disable_interrupts(INT_PSP);
disable_interrupts(INT_BUSCOL);
disable_interrupts(INT_EEPROM);
disable_interrupts(INT_COMP);
disable_interrupts(GLOBAL);
|
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Oct 09, 2007 6:25 pm |
|
|
Quote: | Hi, as the title suggests I'm experiencing a problem with the RB interrupt service being called when I have explicitly disabled all interrupts. |
This shouldn't happen. Interrupts are disabled by default upon power-on
reset.
1. Do you have the NOLVP fuse enabled ? You need it.
2. Do you have a 100 nF (0.1 uF) capacitor between each Vdd pin
and ground ? (A total of two caps). |
|
|
Riddick
Joined: 09 Oct 2007 Posts: 9
|
|
Posted: Tue Oct 09, 2007 6:38 pm |
|
|
Hi PCM programmer, thanks for the speedy reply.
Yes I have the NOLVP fuse enabled. I've run into that problem on another project.
The device package is a 44PLCC with a through hole socket. I have both VDD pins connected together via a track that runs on the solder side of the board, beneath the socket itself. I have a single 104 ceramic capacitor as close to the device as phyiscally possible, connected to the track that links both VDD pins.
Do you think I should add a second capacitor? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Oct 09, 2007 6:47 pm |
|
|
It wouldn't hurt. Is this a 2-layer board ? If it is, how are the
power and ground tracks laid out ? Ideally they should be gridded.
This means they should look like a pattern of horizontal and vertical
streets so that there are many paths for the current to flow through.
There should be no stubs, or if there are, they should be very short,
like 6 mm max.
(I.e., avoid "cul-de-sacs" on power and ground connections.) |
|
|
Riddick
Joined: 09 Oct 2007 Posts: 9
|
|
Posted: Tue Oct 09, 2007 7:30 pm |
|
|
Yes it's a two layer board.
Unfortunately, the extra capacitor hasn't helped.
The board has a grid on both layers, 8 thou tracks at 20 thou spacing. All "dead" copper is removed. Both grids are 0v. 5v is routed to all necessary components using 20 thou tracks using the most direct route possible.
I've played with the fault some more. It seems RB4 isn't having any effect. RB6 and RB7 seem to cause a lockup, RB5 seems to either reactivate the process (from lockup), reset the device, or trigger the ISR and then reset the device, just at random.
It seems I can switch from 0v to 5v logic level without causing any fault on all three inputs that are causing a problem, yet if I switch from 5v to 0v that is when the faults are occuring.
I've tried multiple Pic's and multiple PCB's. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Oct 10, 2007 2:26 pm |
|
|
Quote: | 5v is routed to all necessary components using 20 thou tracks
using the most direct route possible. |
This sounds like the +5v is not gridded, and it needs to be. If your
Vdd power track going to the PIC is a stub, then there is likely to be
a lot of noise at the Vdd pins on the PIC.
Also 20 mils is too small for power and ground. It ought to be 50 mils
or more.
If possible, try testing it on a 4-layer board. For example, the PicDem2-
Plus board is four layers. |
|
|
Riddick
Joined: 09 Oct 2007 Posts: 9
|
|
Posted: Thu Oct 11, 2007 1:46 am |
|
|
Ok, the problem turned out to be the filter caps a co-worker told me to add to the switched inputs. They weren't in the original design and they seemed to be causing problems.
The good thing about finding the fault is that it wasn't some setting I'd overlooked in the programming.
Thanks again for all of your suggestions PCM Programmer.
I do actually have both the top layer and bottom layer grids connected to 0v and I've seen that used quite a bit. I've heard of having the +ve power on a grid also, but thought it was only used commonly on boards with more than 2 layers.
Do you know of any online documentation that talks about having the +ve rails on a grid? I'd like to learn more about it.
Also, you suggest 50 thou tracks minimum for power, is that for noise rejection reasons? I'd be interested in any info on that also. I calculate the best track size based on current requirement.
I'd also have to neck down to 20 thou at the end of the run where the PLCC44 socket is anyway if I used a wider track to route power as 20 thou is the largest that will fit through the pins. |
|
|
|