PDA

View Full Version : Debugin Causesing Restart



IceCube
- 2nd September 2004, 01:33
Hi,

Can someone please tell me what I am doing wrong.
I want to DEGUGIN a character and branch according to its value.
However, typing any character causes a reset!!

Thank you
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ LIST P=PIC16F648A
@ __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF & _BODEN_ON & _PWRTE_ON

DEFINE OSC 04

Define DEBUG_REG PORTB
Define DEBUG_BIT 5
define DEBUG_BAUD 9600
Define DEBUG_MODE 1

Define DEBUGIN_REG PORTB
Define DEBUGIN_BIT 4
Define DEBUGIN_BAUD 9600
Define DEBUGIN_MODE 1

x var byte
CR con $0D 'Carriage Return
LF con $0A 'Line Feed

Start: CMCON = 7
PortA = 0:TRISA = 0
PortB = 0:TRISB = 0
PIR1 = 0
PIE1 = 0
clear
pause 500
debug "We are alive...",cr,lf ' Say hello
pause 500

TestLoop: debug "Enter A or B "
debugin 20000,NoReply,[x] ' wait 20 seconds reply
debug x,cr,lf 'echo back
if x="A" then debug "AAAAAAAA",cr,lf
if x="B" then debug "BBBBBBBB",cr,lf
pause 500
goto TestLoop
NoReply: debug "TimeOut...",cr,lf
pause 500
goto TestLoop

end

Darrel Taylor
- 30th September 2004, 01:20
You currently have the pin that is to be receiving the character set as an output.

PortB = 0:TRISB = 0

Since the debug mode is 1, it's using inverted rs232. Inverted rs232 will idle low, so as long as it's idling everything will be ok.

Once you try to send something the input will go high, but since the pin is set to output and initialized low, you effectively have a short. This will cause a reset.

Also, there is no Define DEBUGIN_BAUD
The IN baudrate is always the same as the DEBUG_BAUD

HTH,
    Darrel