you do not say if the fet is PCh or N ch , but have you tried clearing the port after after assigning the TRIS register . It be helpfull if you included the area of code that you use to configthe chip , assuming its not changed on the fly in other parts of the code
this for the PIC 16F1825 , so should be trhe same for your pic
Code:' config for 16F1825 #CONFIG ;----- CONFIG1 Options -------------------------------------------------- __config _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_ON & _MCLRE_ON & _CP_OFF & _CPD_OFF & _BOREN_ON & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_ON ;----- CONFIG2 Options -------------------------------------------------- __config _CONFIG2, _WRT_OFF & _PLLEN_ON & _STVREN_ON & _BORV_HI & _LVP_OFF #ENDCONFIG '----------- 16F1825 - PIC chip settings -------------------- OSCCON = $70 ' Select 32Mhz , internal clock ( 8Mhz when conf2 - PLLEN_OFF) ' Bit 7 0 = 4xPLL disabled 1= 4xPLL enables ( overrided by conf word 2 setting - PLLEN) ' bits6-3 - 1111 = 16Mhz , 1110 = 8MHz or 32Mhz ( depends on 4xPLL - conf word 2) 1101 = 4 MHz, 1100 = 2MHz 1011 = 1MHz ' bitS 0-1 - 00= Clock set by Conf word ,01 = Timer1 OSC , 1x = internal Osc Block APFCON0 = %00000000 ' All Default - No change when using SPI use SDO1 = RC2 , bit6=0 APFCON1 = %00000000 ' All Default APFCON1 = %00000000 CM1CON0 = $00 ' Disable / Clear comparator 1 CM1CON1 = $00 ' Used with CM1CON0 CM2CON0 = $00 ' Disable / Clear comparator 2 CM2CON1 = $00 ' Used with CM2CON0 CMOUT = $00 ' Disable Comparitors output register - used only if comparitor on ANSELA = %00000000 ' Set Port A - Digital I/O , 0 = Digital 1 = Analog ANSELC = %00000000 ' Set Port C - Digital I/O , 0 = Digital 1 = Analog INLVLA = %00000000 ' Set Port A to TTL Levels 0 = TTL , 1 = SCHMITT TRIGGER - Used port reads and Interupt on Change INLVLC = %00000000 ' Set Port C to TTL Levels 0 = TTL , 1 = SCHMITT TRIGGER - Used port reads and Interupt on Change SRCON0 = %00000000 ' Disable Latched Outputs SRCON1 = %00000000 ' Used with SRCON0 register ADCON0 = $00 ' Disable A/D ADCON1 = $00 ' Disable A/D - used with ADCON0 settings WPUA = %00001000 ' Port A - Turn off week Pullups 1=ON , for each port ( globle enable set in option_reg.7)set wpu on PortA.3 as input only - ref spec WPUC = %00000000 ' Port C - Turn off week Pullups 1=ON For each port DACCON0 = $00 ' Disable D/A DACCON1 = $00 ' Disable D/A - used with DACCON0 FVRCON = $00 ' Disable Fixed Voltage Ref OPTION_REG.7 = 1 ' Weak Pullups disabled 1 = globel disable 0 = globel enable ( set by each port - WPUA & WPUC settings) OPTION_REG.6 = 0 ' Interupt on Falling Edge of INT pin 0= falling edge 1= rising edge OPTION_REG.5 = 0 ' TMR0 clock source - 1=T0clk pin 0=internal clock OPTION_REG.4 = 0 ' TMR0 0=L/H of TOCKI pin 1=H/L of TOCKI pin OPTION_REG.3 = 0 ' Use Prescaller for TMR0 0= Yes , 1 = No OPTION_REG.2 = 1 ' Timer0 prescaler Rate Select bits 2-0(set to 1:256) OPTION_REG.1 = 1 ' 000 = 1:2 , 001= 1:4 , 010 = 1:8 , 011 = 1:16 OPTION_REG.0 = 1 ' 100 = 1:32 , 101 = 1:64, 110 = 1:128 , 111 = 1:256 T1CON = %01110100 ' Timer 1 ,bit7-6 = TMR1 CLK source 00 = Instuction Clk(Fosc/4),01 =sys clk,10=ext clk,11=cap sense osc ' bit5-4 = TMR1 prescale 11= 1:8 ,bit3=0 LP off,bit2=1 no sync ext CLK ,bit1= 0 n/a,Bit0=0 Timer 1 on/off T1GCON = %00000000 ' Timer 1 Gate Control bit7 0= counts regardless of gate 1 = gates in use , bit6 gate active when 1= High ,0=low ' bit5 0= toggle mode diabled 1= enabled bit4 single pulse mode 1- en 0= dis, bit 2 -status bit,1-0 - gate source sel T2CON = %01110011 ' Timer 2 off + 1:15 postscale ,1:64 prescale ( bit 7 = x, bit6-3 1110 = 1:15 postscale, bit2=0 timer off ,bit1-0 = prescale 10 = 16 , 11= prescale 64 T4CON = %00000000 ' POSTSCALER 1/1,STOP,PRESCALER 1/1 T6CON = %00000000 ' POSTSCALER 1/1,STOP,PRESCALER 1/1 TMR0 = 0 ' Clear TMR0 MODULE REGISTER TMR1H = 0 ' CLEAR TMR1H MODULE REGISTER TMR1L = 0 ' CLEAR TMR1L MODULE REGISTER TMR2 = 0 ' CLEAR TMR2 MODULE REGISTER TMR4 = 0 ' CLEAR TMR4 MODULE REGISTER TMR6 = 0 ' CLEAR TMR6 MODULE REGISTER 'PR2 = 255 ' Timer 2 Preload value 'PR4 = 255 ' Timer 4 Preload value 'PR6 = 255 ' Timer 6 Preload valueCode:TRISA = %00001000 ' setup Port A input=1,output=0 for I/O pins ( Note RA3 - input only - refer spec) TRISC = %00000000 ' setup Port C input=1,output=0 for I/O pins PORTA = %00000000 ' clear PORTC = %00000000 ' clear




Bookmarks