Has anyone experienced troubles with PORTA on this processor? What I have is an NPN (2N4401) transistor connected with a 1.5M resistor=20 to the base of a PNP (TIP115) through a 100K resistor (the TIP115 has an=20 HFE of 1000+ and the 2N4401 as one of 100 to 300). My Code is relatively=20 simple and straight forward. I store the state of PORTA in a variable called G_PORTA which is in the=20 common register file location (0x70 to 0x7F). I AND the TRISA register with ~0x03 (RA0 RA1 are outputs all others=20 inputs). Then I write the G_PORTA data to the port directly. Some code might help. Yes I have interrupts setup but I make sure that the state of the port is= =20 written durring the interrupt. Macro definitions --------------------------------8<------------------------8<-------------= ----------------- P_A_HIGH EQU D'1' ; Power ON is active when output is HIGH G_TICK_0 EQU 0 ; timer zero flag G_PON EQU 1 ; Power on Flag G_TICK_P EQU 3 G_TX_A EQU 6 ; Transmit queue ACTIVE G_RX_A EQU 7 ; Data recieved (ACTIVE) #define G_TZERO G_FLAGS, G_TICK_0 #define G_POWER_ON G_FLAGS, G_PON #define G_XMITING G_FLAGS, G_TX_A #define G_RECIEVED G_FLAGS, G_RX_A #define G_TOGGLE G_FLAGS, G_TICK_P G_FLAGS EQU 0x070 ; General Flags ; PORT output status information G_PORTA EQU 0x07A ; PORT A output status G_SCRATCH EQU 0x07B ; Global scratch pad ; global countdown timer memory G_TICK EQU 0x07D #define MASK G_SCRATCH ; temporary status register during interrupt I_W EQU 0x07E I_STATUS EQU 0x07F ON EQU D'1' OFF EQU D'0' AUX_POW MACRO ON_OFF_STATE ; set on off state IF ON_OFF_STATE =3D=3D D'1' IF P_A_HIGH =3D=3D D'1' bsf G_PORTA, P_ON ELSE bcf G_PORTA, P_ON ENDIF ELSE IF P_A_HIGH =3D=3D D'1' bcf G_PORTA, P_ON ELSE bsf G_PORTA, P_ON ENDIF ENDIF ENDM BSELF MACRO BANK CUR_RP1 =3D (BANK >=3D2) CUR_RP0 =3D ((BANK & 1)>0) IF BANK < 2 bcf STATUS, RP1 ELSE bsf STATUS, RP1 ENDIF IF (BANK & 1) < 1 bcf STATUS, RP0 ELSE bsf STATUS, RP0 ENDIF ENDM BSEL MACRO BANK BSELF BANK ENDM --------------------------------8<------------------------8<-------------= ----------------- actual Code --------------------------------8<------------------------8<-------------= ----------------- BSELF 0 ; always clear this bcf INTCON, RBIF TIMER2: btfss PIR1, TMR2IF ; if (PIR1) ; if timer2 interrupt goto TIMER2_END ; { bcf PIR1, TMR2IF ; PIR1 =3D 0; ; clear intterupt ; set RA1 and RA0 for output movlw ~ (0x02 | 0x01) BSEL 1 andwf TRISA, F ; TRISA =3D ~(0x03); ; toggle every 1/100th of a second movlw (1 << P_ON2) ; G_PORTA ^=3D (1 << P_ON2); xorwf G_PORTA, F ; toggle port state AUX_POW(OFF) ; AUX_POW =3D OFF; btfsc G_POWER_ON ; if (G_POWER_ON) AUX_POW(ON) ; AUX_POW =3D ON; movf G_PORTA, W ; BSEL 0 ; movwf PORTA ; PORTA =3D G_PORTA; ; that's it really except... movf G_TICK, F ; check G_TICK btfsc STATUS, Z ; if (G_TICK =3D=3D 0) bsf G_TZERO ; ZERO_F =3D 1; btfss STATUS, Z ; else decf G_TICK, F ; G_TICK--; TIMER2_END: .... POWER_ON: bsf G_POWER_ON ; set the power on bit AUX_POW(ON) movf G_PORTA, w BSEL 0 movwf PORTA return POWER_OFF: bcf G_POWER_ON AUX_POW(OFF) movf G_PORTA, w BSEL 0 movwf PORTA return --------------------------------8<------------------------8<-------------= ----------------- The G_POWER_ON bit gets toggled in the POWER_ON / POWER_OFF subroutines (it's a flag not really used to tell the system to turn power on or off=20 just a flag to indicate it IS off). There are 2 powersupplies if you are wondering (small chuckle). The PIC=20 turns on and off the major supply and runs off a tiny one (78L05=20 delivering a whole 5ma of power for the PIC). The P_A_HIGH bit is becaus= e=20 the pruduction unit will have an active low on input instead of an active= =20 high one (used here), it will have a switching regulator instead of a=20 cheap pile O parts (smile). What happens you may wonder, well nothing, it never turns on that's what=20 has me pulling hair. CONFIG bits ; __CONFIG _CP_OFF & _DATA_CP_OFF & _WDT_ON & _BOREN_ON & _PWRTE_ON &=20 _INTRC_OSC_NOCLKOUT & _MCLRE_OFF & _LVP_ON __CONFIG _CP_OFF & _DATA_CP_OFF & _WDT_OFF & _BOREN_ON & _PWRTE_ON &=20 _INTRC_OSC_CLKOUT & _MCLRE_OFF & _LVP_ON I don't have MCLR being used save internally. I yanked the watchdog timer= =20 to be sure that wasn't the problem. Ideas? Bad Jokes? Redicule? :) The first one is most appreciated ;) Stephen --=20 Stephen R. Phillips was here -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body