hello all
i got a new problem around portb4:7. because i have a device out with this inputs interruptable where allways some problems occur (pic seems like frozen, must be repowered again) i start to try something.
a simple code like below stops to run when i connect RB6 (only this one makes problems it seems) to a long cable (about 30m) with no connection at the other end!!! no charm!
the led goes out and nothing happens again. test it on the lab-x2 and it must be made a reset.
when i uncomment te additional three lines in the main loop, sometimes it is possible to restart the code again with some connect rb6 and reconnect.
anyone an idea why this could be? works it like an antena? ways to try further on?
thanks a lot for any hint
Code:
include "modedefs.bas" ' include serial modes
'-- FUSE CONFIGURATIONS -----------------------------------------
@ device pic16F876a, hs_osc ' oscillator selection
@ device pic16F876a, wdt_off ' watchdog timer
@ device pic16F876a, pwrt_on ' power-up timer
@ device pic16F876a, bod_on ' brown-out reset
@ device pic16F876a, lvp_off ' low-voltage programming
@ device pic16F876a, cpd_on ' data eeprom protection _on
@ device pic16F876a, wrt_off ' flash program memory write
@ device pic16F876a, protect_on ' program code protection _on
'-- DEFINITIONS -------------------------------------------------
DEFINE OSC 20 ' oscillator speed
'-- PORTS -------------------------------------------------------
led1 var portb.0
led2 var portb.1
led3 var portb.2
but1 VAR portb.4
but2 VAR portb.5
but3 VAR portb.6
'-- CONSTANTS ---------------------------------------------------
'-- VARIABLES ---------------------------------------------------
inp var byte ' inputs portb4:7
'-- INITIALIZATION ----------------------------------------------
init: clear ' set all ram registers to 0
TRISA = %00000000 ' input : an4
TRISB = %11110000 ' input : buttons 1 - 3
TRISC = %10000000 ' input : rx
ADCON1 = 7 ' a/d und comp off; ra = d
OPTION_REG.7 = 0 ' enable portb pull-ups
lcdout $fe,1 ' clear lcd
pause 50 ' wait for start up lcd
portb = 0 ' clear all outputs on portb
'-- MAIN LOOP ---------------------------------------------------
main:
led1 = led1 ^ 1 ' toggle led
'lcdout $fe,$80,"status = ", dec led1, " " ' write led status
'inp = Portb >> 4 ' shift portb inputs
'lcdout $fe,$c0,"b4:7 = ", dec2 inp ' write input value
pause 500
GOTO main
'-- INTERRUPT SERVICE ROUTINE ----------------------------------
'-- SUB --------------------------------------------------------
'-- END ---------------------------------------------------------
END
'----------------------------------------------------------------
Bookmarks