View previous topic :: View next topic |
Author |
Message |
Pekub
Joined: 20 Dec 2005 Posts: 16
|
Reset on IO pin |
Posted: Fri Mar 18, 2011 7:32 am |
|
|
I have a very simple program for PIC16F1824.
Compiler V 4.119
If I set low level on the RA2 pin, the processor resets.
When I delete a row with the settings pull up, it's all okay.
Please, what is wrong ?
Code: |
#include <16F1824.h>
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES NOMCLR
#FUSES NOWDT //Watch Dog Timer
#FUSES NOPUT //Power Up Timer
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#use delay(clock=16000000)
#zero_ram
void main()
{
disable_interrupts(GLOBAL);
setup_oscillator(OSC_16MHZ|OSC_INTRC|OSC_PLL_OFF,0);
setup_adc_ports(ADC_OFF);
// whith this code, procesor reset when RA2 -> 0
port_a_pullups(TRUE);
port_a_pullups(0x04); // pullup odpor na PIN_A2
// whith this code, it's O.K.
// port_a_pullups(TRUE);
// port_a_pullups(0x04); // pullup odpor na PIN_A2
while(TRUE)
;
} |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Mar 18, 2011 11:49 am |
|
|
Remove the #zero_ram line. It may be over-writing something.
Also, simplify the program. Remove the setup_oscillator() line.
Change the #use delay() to 4MHz. |
|
|
Pekub
Joined: 20 Dec 2005 Posts: 16
|
|
Posted: Fri Mar 25, 2011 3:50 am |
|
|
Thank you for your ideas. I tried them.
I found that this problem is not with the pull up resistor.
The problem is not software but hardware.
Input A2/INT in this chip is very sensitive to noise and interference, what causes a processor reset. I decided to use this pin as an output. |
|
|
|