View previous topic :: View next topic |
Author |
Message |
Thorsten Guest
|
EXT INT ON PIC18F1230 |
Posted: Mon Oct 08, 2007 8:28 am |
|
|
Hi,
i want to create an external Interupt on PIN A0 (INT0). My Problem is that the PIC doesn´t jump to the ISR.also wdt is off!!
Have anyone this Problem befor?
Thanks for your help!
Thorsten
Here is my code:
#include "main.h"
#int_EXT
void EXT_isr(void)
{
output_high(PIN_B0);
delay_us(10);
output_low(PIN_B0);
}
void main()
{
set_tris_a(0x01); set_tris_b(0xdc);
setup_adc(ADC_OFF|ADC_TAD_MUL_0);
setup_adc(ADC_CLOCK_INTERNAL|ADC_TAD_MUL_0);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
ext_int_edge( H_TO_L );
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
while(TRUE)
{
}
}
Here my Header file
#include <18F1230.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES H4 //High speed osc with HW enabled 4X PLL
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES BROWNOUT //Reset when brownout detected
#FUSES BORV20 //Brownout reset at 2.0V
#FUSES PUT //Power Up Timer
#FUSES NOCPD //No EE protection
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOXINST //Extended set extension and Indexed Addressing mode enabled
#FUSES NOWRT //Program memory not write protected
#FUSES NOWRTD //Data EEPROM not write protected
#FUSES NOWRTC //configuration not registers write protected
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOEBTRB //Boot block not protected from table reads
#FUSES MCLR //Master Clear pin enabled
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOCPB //No Boot Block code protection
#FUSES NOWRTB //Boot block not write protected
#FUSES BBSIZ512 //Boot block size 512 bytes
#FUSES FLTAA5 //FLTA multiplexed on A5
#FUSES T1OSCA6 //T1 oscillator pin on A6
#FUSES NOPWMPIN //PWM outputs disabled upon Reset
#FUSES HPOL_HIGH //High-Side Transistors Polarity is Active-High (PWM 1,3,5 and 7)
//PWM module high side output pins have active high output polarity
#FUSES LPOL_HIGH //Low-Side Transistors Polarity is Active-High (PWM 0,2,4 and 6)
//PWM module low side output pins have active high output polar
#use delay(clock=40000000) |
|
|
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
|
Posted: Mon Oct 08, 2007 8:39 am |
|
|
Add a NOLVP fuse (if you're not low voltage programming.)
I'm not sure, but before your main loop, you may want to read the PIN_A0 to ensure that it is configured as an input? |
|
|
Ttelmah Guest
|
|
Posted: Mon Oct 08, 2007 8:43 am |
|
|
A0, is not the EXT interrupt.
The EXT interrupt, is on _B0_, which you are using as an output...
You need to rethink your pins used.
Best Wishes |
|
|
Thorsten Guest
|
|
Posted: Mon Oct 08, 2007 9:56 am |
|
|
At the PIC18F1230 the PIN-A0 is the INT0 Interupt input. |
|
|
Ttelmah Guest
|
|
Posted: Mon Oct 08, 2007 10:29 am |
|
|
Sorry, confused 1230, with 1320...
I'd suspect your problem is with the ADC configuration. You cannot have multiple setup_adc lines. Only the last one will apply if you do this, and your last one, does not turn off the ADC.
Just use:
setup_adc(ADC_OFF);
Best Wishes |
|
|
Thorsten Guest
|
|
Posted: Tue Oct 09, 2007 12:40 am |
|
|
That was a good hint but it doesn`t work. If i change to PIN-B3 (INT3) it work ´s fine. I also think that i have a problem with the PORTA settings, but i can´t find my problem. |
|
|
Thorsten Guest
|
|
Posted: Tue Oct 09, 2007 12:57 am |
|
|
Hi, my problem is solved. CCS Compiler don´t setup the ADCON1 Register correct. Bit 0 have to be 1, for digital Input.
Thanks for your help |
|
|
|