Quantcast
Channel: MEL PICBASIC Forum
Viewing all articles
Browse latest Browse all 4746

Pic 12F675... Pulling GPIO.3 Low resets program

$
0
0
I've been at this for hours... so bare with me please.

I have a 10k pullup on port 3 (GPIO.3) and set it to input. I have the wiper of a 10k pot connected to GPIO.2 and have it set to analog input. I am not currently using it in the program but plan to, so ADCON0 and ANSEL reflect the planned future use (in case I have something screwed up there). Port 2 is the only analog input port.

I have an LED and Relay connected to ports 0 and 1 respectively.

With the program below, an LED and a Relay turn on and turn off every two seconds repeatedly.

But when I push a button connecting port 3 to ground, all action from the LED and Relay stops (as though I've shorted out the 5v supply). I have checked the supply voltage at the pins of the processor and grounding port 3 has no effect on the supply voltage.

When the button is released, the LED and Relay return to normal function.

NOTE: I added the toggling relay just before "Main" to help me understand what was happening. Pushing the button apparently resets the chip because the relay "buzzes" when it is pressed and released.

Why would bringing input port 3 to ground cause a reset?

Thank you!

Ross


Code:

      Define OSCCAL_1K 1  ' Calibrate internal oscillator
 
  TRISIO = %00111100  ' GPIO.2,3,4 and 5 INPUTS, GPIO.0 and 1 OUTPUTS
  ADCON0 = %10001001  ' Turn on A/D module, Enable AN2, R Justify Result
  ANSEL  = %00100100  ' Fosc /32, Set AN2 analog, the rest digital
  CMCON = 7          ' Analog comparators off
  WPU = %00110000    ' Turn on weak pullups on GPIO.4 and 5
 
  LED VAR GPIO.0
  RELAY var GPIO.1
  I var byte
 
  for i = 1 to 10      'This put in to buzz relay at start of program
  toggle relay     
  pause 50
  next i
 
Main: 
    HIGH LED        'Turn on LED
    low relay        'Turn on Relay
    pause 2000     
    LOW LED        'Turn off LED
    high relay        'Turn off Relay
    Pause 2000
    goto main        'Do it again...
    end


Viewing all articles
Browse latest Browse all 4746

Trending Articles