View previous topic :: View next topic |
Author |
Message |
rudy
Joined: 27 Apr 2008 Posts: 167
|
18F46K22 EXTERNAL INT [Solved] |
Posted: Thu May 26, 2022 8:07 am |
|
|
Hi there.
Do I need to do any other thing when I use external int 0 on this chip? Because I feed the RB0 with 1Hz pulse, it seems that the ISR ignores the low state of the pulse.
Code: | SETUP_ADC_PORTS(NO_ANALOGS);
SETUP_COMPARATOR(NC_NC_NC_NC);
SETUP_COUNTERS(RTCC_INTERNAL,RTCC_DIV_16);
SETUP_TIMER_1(T1_DISABLED|T1_DIV_BY_1);
SETUP_TIMER_2(T2_DISABLED,0xFF,16);
SETUP_TIMER_3(T3_DISABLED|T3_DIV_BY_8);
SETUP_TIMER_4(T4_DISABLED,0xFF,16);
SETUP_TIMER_5(T5_DISABLED|T5_DIV_BY_8);
SETUP_TIMER_6(T6_DISABLED,0xFF,16);
SET_TRIS_A(0b00000000);
SET_TRIS_B(0b11100001);
SET_TRIS_C(0b11111111);
SET_TRIS_D(0b11111111);
SET_TRIS_E(0b11111111);
PORT_B_PULLUPS(FALSE);
EXT_INT_EDGE(0, L_TO_H);
SETUP_CCP1(CCP_CAPTURE_RE);
ENABLE_INTERRUPTS(INT_EXT); //ENABLE RTC INTERRUPTS
// ENABLE_INTERRUPTS(INT_CCP1); //INABLE INFRARED INTERRUPTION
ENABLE_INTERRUPTS(GLOBAL); //ENABLE GLOBAL INTERRUPTS |
Code: | #INT_EXT //RTC SR
void RB0_ISR(void)
{
SEGUNDOS++;
if(SEGUNDOS>=60)
{
SEGUNDOS=0;
MINUTOS++;
}
if(MINUTOS==60)
{
MINUTOS=0;
HORAS++;
}
if(HORAS==24)HORAS=0;
CLK=1;
} |
When bit CLK is set, I do some other things on the program, but, somehow, it seems to be always been set on the ISR.
Taking a look at datasheet, I saw that RB0 is also used on SR LATCH and ECCP, but I cannot see any relation to these functions.
Regards; |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu May 26, 2022 10:17 am |
|
|
What is the Vdd voltage of your PIC ?
What are the voltage levels (high and low) of the 1 Hz pulse ?
If your PIC is running at 5.0v, the 1 Hz pulse needs to be at
least 4.0v for the high level. Ideally it should be higher.
The low voltage level should be a max of 0.8v and ideally lower. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19505
|
|
Posted: Thu May 26, 2022 10:53 am |
|
|
Er. Not sure what you mean, but it will 'ignore the low state'. The
interrupt will trigger when the signal goes high.... |
|
|
rudy
Joined: 27 Apr 2008 Posts: 167
|
|
Posted: Thu May 26, 2022 11:29 am |
|
|
Weird!!!!
I may did some mistake. Suddenly, the problem vanishes....
The 1HZ is 0-5V.
It is OK now, working fine.
Regards! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu May 26, 2022 11:41 am |
|
|
Quote: | EXT_INT_EDGE(0, L_TO_H); |
In your original posted code, show above, you have it set to trigger on
the rising edge. When it goes from low to high, it will trigger.
Quote: | interrupt will trigger when the signal goes high.... |
It's doing exactly what you told it to do above. |
|
|
rudy
Joined: 27 Apr 2008 Posts: 167
|
|
Posted: Thu May 26, 2022 11:46 am |
|
|
No issues..
There is an BC-548 transistor driving the signal before it enter on RB0, the +5V was loose on the collector, and that's was the problem.
I sorry to disturb.. Once that this thread don't help much, please delete it from the forum.
I apologize the mistake.
Regards, |
|
|
|