News:

Let's find out together what makes a PIC Tick!

Main Menu

abnormal behavior icps outputs PORTB.7 PORTB.6

Started by Giuseppe, Oct 04, 2021, 09:03 AM

Previous topic - Next topic

Giuseppe

Hello everyone
i am trying to use icps programming output. I can't control it to flash a led.
To consider that the led with its current limiting resistor is inserted after removing the icps connector.
In the programming phase both the pgd and the pgc are isolated from everything.
You have no commands in portb.7 or portb.6 do not respond
Under the program:
Device = 16F1827

Config1 FOSC_INTOSC, WDTE_OFF, PWRTE_ON, MCLRE_ON, CP_ON, CPD_ON, BOREN_ON, CLKOUTEN_OFF, IESO_OFF, FCMEN_OFF
Config2 WRT_OFF, PLLEN_OFF, STVREN_OFF,LVP_OFF 'BORV_LO

Xtal 8

OSCCON = %01110000      '
OPTION_REG = %00000111  '

'-----Set seriale hardware-------

Declare Hserin_Pin PORTB.1    'PIN 7 Rx 16f1827
Declare Hserout_Pin PORTB.2   'PIN 8 Tx 16f1827
Declare Hserial_Baud 2400
Declare  Hserial_TXSTA = %00100100 ' tx a 8bit (bit6) high speed on (bit2)
Declare  Hserial_RCSTA = %10010000 ' bit 6 a 0  Rx a 8 bit 
Declare  Hserial_Clear = On

'---Set Port----------------------------------------------------

LATA  = %00000000     'pag.122
LATB  = %00000000
TRISA = %00111100
TRISB = %00111011
WPUA = %00100000 '
WPUB = %00111001 '
CM1CON0.7 = 0    '
CM2CON0.7 = 0    '
SRCON0.7 = 0     '
Clear ANSELA     '
Clear ANSELB
'APFCON0 = 0      '
'APFCON1 = 0

'--------Set Interrupt----------
 
INTCON = %00000000
PIE1 = %00000000    '
PIR1 = %00000000    '

'------Set Tmr1------------

T1CON =%00111101 ' 
T1GCON=%00000000 '      
TMR1H = 60       '
TMR1L = 170

'----------------
Dim x As Byte             '

'------Symbol--------------
Symbol GIE = INTCON.7
Symbol PEIE = INTCON.6
Symbol RCIE = PIE1.5
Symbol RCIF = PIR1.5
Symbol TMR1IE = PIE1.0
Symbol TMR1IF = PIR1.0

Symbol dip_1 = PORTA.2 '
Symbol dip_2 = PORTA.3 '
Symbol dip_3 = PORTA.4 ' 
Symbol dip_4 = PORTB.0 '

Symbol foto_3 = PORTB.3     '
Symbol foto_2 = PORTB.4
Symbol foto_1 = PORTB.5     '
Symbol led = PORTB.6        '
Symbol rel_1 = PORTA.7
Symbol rel_2 = PORTA.0
Symbol rel_3 = PORTA.1
Symbol m_set = PORTA.6

'-------------------------------

led = 0
DelayMS 200
Low PORTB.7

Do

For x = 0 To 7 '
 Clrwdt
 'Toggle latb.6'led
 High PORTB.6
 DelayMS 100
 Low PORTB.6
 DelayMS 100
Next x

Loop

End

JonW

Simulates ok in Isis.  If i am writing to a port I use Latc.X to write to the port latch direct


Giuseppe

I tried to use high latb.6 and low latb.6.
but I can't control the door

Yasin

MDCARH, CPSCON0, CPSCON1, CMxCON0, CMxCON1
It is necessary to check these registers. Some hardware may be staying powered on. For example, Capacitive Sensing Module

Giuseppe

Set the registers indicated above but nothing the pin remains high I can not control it

MDCARH = %10000000 '
CPSCON0 = %00000000 '
CPSCON1 = %00000000

John Lawton

Just a thought, try turning off P1C, P2A and CCP2 as well by clearing CCPxCON registers

John

Stephen Moss

I can't see anything obviously wrong with the set up, however you do not appear to have not set all the config fuses. Maybe things have changed but I seem to recall that for non 18F devices your configuration has to list them all.
If you are using the original Mechanique IDE I suggest installing the Fuse Configurator Plug-in otherwise try the Positron Studio IDE which as it built in. The fuse of importance in regard to your problem could be the Debug Fuse as it has to be off for the ISCP Clock and Data pins to act as I/O pins, although the default at power up should be off, it would be wise to set it anyway in case there is a problem with the power on reset value.

If that does not solve it and your LED is not in the wrong way round then try stripping your code down to...
Device = 16F1827

Config1 FOSC_INTOSC, WDTE_OFF, PWRTE_ON, MCLRE_ON, CP_ON, CPD_ON, BOREN_ON, CLKOUTEN_OFF, IESO_OFF, FCMEN_OFF
Config2 WRT_OFF, PLLEN_OFF, STVREN_OFF, LVP_OFF, BORV_LO, DEBUG_OFF, PLLEN_OFF

Xtal = 8

OSCCON = %01110000      '
OPTION_REG = %00000111  '

TRISA = $00
TRISB = $00

Main:
PortA = $00
PortB = $00
DelayMs 500
PortA = $FF
PortB = $FF
DelayMs 500
Goto Main
It just toggles all the pins on both ports between high and low for half a second.

If you still get nothing happening on any pin then you should look towards your ICSP connections and you programmer settings to ensure it is using high voltage programming as it could be the device is not being programmed.
However, if the problem is confined to just PortB.6 and PortB.7 then I am not sure what the problem could be although I would be considering that either there is a problem with PIC or the pins are shorted to GND externally.

Giuseppe

Banging my head for several hours I found that the problem lies with these lines of code :

'T1CON =%00111101 ' 
'T1GCON=%00000000 '        '
'TMR1H = 60       '
'TMR1L = 170

once these lines of code are excluded both portb.6 and portb.7 I can control them.
it could be a problem of comfort with setting the timer1

John Lawton

Timer 1 is used by the PWM, so clear the CCPxCON registers

Yasin

Have you tried T1OSCEN ie T1CON.3 bit disable?