Im confused too 
I turned the watchdog timer off and the chip stopped resetting itself after a few seconds. I dont know why it suddenly started in the first place. Maybe its because the main loop hardly does anything and it thought it had crashed.
Now back to the original problem. When the 555 is plugged in the PIC turns outputs on/off randomly. The strange thing is that it only seems to cause a problem when the PIC runs a pause command.
The current code is as follows.
Code:
'Define the oscillator (20MHz)
DEFINE OSC 20
x var byte
'Set the tris registers
TRISA=%00000011
TRISB=%00000100
'ANSEL = 0
'ADCON0 = 0
'ADCON1 = 0
CMCON = 7
CVRCON = 0
CCP1CON = 0
'Define output pins
pSocket1 VAR PORTA.2
pSocket2 VAR PORTA.3
pSocket3 VAR PORTA.4
pSocket4 VAR PORTB.0
pSocket5 VAR PORTB.1
pSocket6 VAR PORTB.3
pPower VAR PORTB.7
pStatus VAR PORTB.4
pData VAR PORTB.6 'Switches between Master and Slave
'Define input pins
iSensor1 VAR PORTA.0
iSensor2 VAR PORTA.1
low pstatus
for x=0 to 10
high ppower
pause 100
low ppower
pause 100
next
'BEGIN: Main loop
loop:
ppower=isensor1
pstatus=isensor2
GOTO loop
It should make the power light flash a few times then use the power and status LEDs to show the state of the 2 sensors. Whats weird is that the chip gets stuck on the for loop when the 555 is connected. The power LED flickers randomly. If i take the 555 out then it will run as normal and enter the main loop. Once in that loop i can put the 555 back in and it seems to be running as it should.
On the circuit the 555 and ceramic resonator are right next to each other. Could that be why only the pause command seems to be affected?
One other thing i think i should mention. The 555 part is to make IR transmitters flash at 38.5KHz. In a previous thread someone said i should also have pulses. I didnt have enough spare pins on the PIC to control those pulses and my breadboarded version worked fine without them. Could that cause this problem?
Bookmarks