I can turn on any of the ports using realterm and a max232 using the code below.
Much stuff just commented out, serouts added so as to see variable contents, a blinky added for life signs, easy to undo. Thanks for sharing your problem, I got to learn too.Code:INCLUDE "MODEDEFS.BAS" ;@ DEVICE PIC16F628a,XT_OSC ;@ DEVICE pic16F628a, WDT_OFF ;@ DEVICE pic16F628a, PWRT_ON ;@ DEVICE pic16F628a, MCLR_ON ;@ DEVICE pic16F628a, BOD_ON ;@ DEVICE pic16F628a, LVP_OFF ;@ DEVICE pic16F628a, CPD_OFF ;@ DEVICE pic16F628a, PROTECT_OFF @MyConfig = _HS_OSC & _WDT_OFF & _PWRTE_ON & _LVP_OFF @MyConfig = MyConfig & _BODEN_OFF @ __config MyConfig DEFINE OSC 20 CMCON = 7 trisa = %00000010 trisb = %00000000 PORTA = 0 PORTB = 0 MYDATA1 VAR byte MYDATA2 var byte address1 var byte address2 var byte checksum var byte chk_sum var byte ;serpin VAR PortA.1 PAUSE 50 loop: high portA.2 pause 500 low portA.2 gosub loop1 serout portA.0,T9600,[254,2,mydata1," ",mydata2," "] serout portA.0,T9600,[$FE,$C0,address1," ",address2," " ] 'CheckSum = (address1 + address2) 'CheckSum = CheckSum + (mydata1 + mydata2) 'IF checksum != chk_sum THEN loop 'IF (mydata1) != (mydata2) THEN loop 'IF (address1) != (address2) THEN loop if mydata1= 86 then toggle portB.0 if mydata1= 89 then 'while mydata1 = 89 ' trying this example for debounce 'pause 50 'wend high PortB.1 else low PortB.1 endif if mydata1 = 90 then 'while mydata1 = 90 'pause 50 'wend high PortB.2 else low PortB.2 endif if mydata1= 101 then 'while mydata1 = 101 'pause 50 'wend high PortB.3 else low PortB.3 endif if mydata1 = 102 then 'while mydata1 = 102 'pause 50 'wend high PortB.4 else low PortB.4 endif if mydata1=105 then toggle PortB.5 if mydata1=106 then toggle PortB.6 goto loop loop1: SERIN2 PortA.1,84,[DEC address1,DEC ADDRESS2,DEC MYDATA1,DEC MYDATA2] Return end




Bookmarks