|
|
View previous topic :: View next topic |
Author |
Message |
OutOfOptions Guest
|
Interrupt controls on 18F8720 (INT_EXT3 and INT_RB) |
Posted: Wed Sep 29, 2004 6:49 am |
|
|
I hope someone can help me out with this.
First Ill introduce the setup/code:
Im using compiler version 3.206.
Setup:
#include <18f8720.h>
#device *=16 ADC=16
#fuses H4,NOPROTECT,NOWDT,NOLVP
#use delay(clock=40000000)
Im using fast_io on Port B:
Pin 1 and 2 are used for LEDs
Port B is pulled up.
Im using two external interrupts, port 3/INT_EXT3 and port 4 to 7/INT_RB:
Enabling:
enable_interrupts(INT_EXT3);
ext_int_edge(3,H_TO_L);
enable_interrupts(INT_RB);
enable_interrupts(GLOBAL);
As well as those, Im also using RDA, RDA2 and TIMER1
The code for the OnChange interrupt is rather trivial:
#int_rb
void /* RET Nothing */
portb_isr(void)
{
int8 changes;
rb_count++;
port_b = input_b();
changes = last_b ^ port_b;
last_b = port_b;
if (bit_test(changes,4 )&& !bit_test(last_b,4)){
if( bit_test(last_b,4)) //if bit x WAS high, its low now
DCD0_val = false;
else
DCD0_val = true;
}
if (bit_test(changes,5)&& !bit_test (last_b,5)){
if( bit_test(last_b,5))
DSR0_val = false;
else
DSR0_val = true;
}
if (bit_test(changes,6)&& !bit_test (last_b,6)){
if( bit_test(last_b,6))
RING0_val = false;
else
RING0_val = true;
}
if (bit_test(changes,7)&& !bit_test (last_b,7)){
//STATUS is active low
if( bit_test(last_b,7))
STATUS_val = true;
else
STATUS_val = false;
}
//crude debounce
delay_ms(50);
}
The 'rb_count' var is simply for debuggin purposes, Ive used it to check how many times the rutine is called. Notice that bit 7 is active low.
The INT_EXT3 rutine:
#int_ext3
void /* RET Nothing */
cts0_input(void)
{
if(CTS0_hi_to_lo)
{
CTS0_flag = true;
if(CTS0_cont_trans)
{
output_interrupt(0);
CTS0_cont_trans = false;
}
}
else
CTS0_flag = false;
disable_interrupts(INT_EXT3);
setup_cts0_int();
RBIF = 0;
//crude debounce
delay_ms(50);
}
I explicitly reset the INT3IF (interrupt flag for INT3) as a debug thing. I checked the LST file, and it is reset anyway.
The code for setup_cts0_int():
void
setup_cts0_int(void)
{
if(CTS0_hi_to_lo)
{
ext_int_edge(3,L_TO_H);
CTS0_hi_to_lo = false;
}
else
{
ext_int_edge(3,H_TO_L);
CTS0_hi_to_lo = true;
}
enable_interrupts(INT_EXT3);
}
Basically, this is last function is there to enable detection of both low to high and high to low transitions.
Now apart from the fact that there is too much code... :D ..I dont register anything on the RB interrupts. The counter increments to 1 after startup, but doesnt get anywhere else.
I tried forcing and output on one of the RB pins (AFTER changing the port to standard_io), and then calling the interrupt rutine from the software. The counter was then 3.
My guess is that Im forgetting something, that disables further calling of the rutine. Ive tried creating hw interrupts (by turning off the device connected to port B4-7 and turning it on again) but nothing helps...
Thank you for your time.[/list] |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Sep 29, 2004 2:37 pm |
|
|
I would make a small test program, that only tests Port B interrupt-on-
change. You have too many other things going on, to properly isolate
the problem with your current program. |
|
|
OutOfOptions Guest
|
|
Posted: Wed Sep 29, 2004 2:52 pm |
|
|
Yeah, Ill do that, but the only thing that has been changed in the HW since that last known (and smoothly running) configuration (HW and SW) are 5 connections on port J, now being on interrupts.
So its fair to say its an interrupt problem (running them with no ints on port B is fine) |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|