News:

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

Main Menu

16F15223 Configuration issue

Started by okmn, May 15, 2024, 03:57 PM

Previous topic - Next topic

Pepe

I don't understand then why the manual clarifies only 0x0B or 0x8B instead of 0x0B 0x8B 0x10B 0x18B ..... etc (All core registers)

top204

It is named "Shared RAM" and it also occupies all RAM banks, and each RAM bank starts at an offset address.

okmn

#42
Quote from: top204 on Jun 03, 2024, 02:51 PMTry replacing the line:

T0CON1 = %01010010

with

T0CON1 = %01000000

You will find it in the Timer0_Init procedure.

It seems as though I forgot to change that SFR's contents and it is set for a PIC18F26K40 device's Timer0 overflow and will actually syncronise the Timer0 and not allow it to work correctly on a PIC16F15223 device. I wish microchip would leave peripherals alone that do not need changing, and at least keep SFR bit settings as standard.


I tried it,
  but it same only RC0 blinking still

ps. :
When i changed the places of LED2_Pin and LED1_Pin, only the ra2 LED gives light, but it is constantly on and does not blink.

trastikata

Hi,

I've just read (skimmed) all posts, just to clarify something - if you place both PORTA.2 and PORTC.0 in the ISR, only PORTC.0 blinks?

- it means the ISR fires correctly.

Outside of the ISR, i.e. in the main loop you are able to toggle both PORTA.2 and PORTC.0?

- it would mean no hardware issues.

Is my summary correct so far?

okmn

Main:
    Setup()                                        ' Setup the program and peripherals

    Do                                              ' Create a loop
        Toggle LED2_Pin  ' LED1_Pin
        'Toggle LED1_Pin                        '    Toggle LED1
        DelayMS 100                                ' Delay for a half a second
    Loop                                            ' Do it forever


////

Proc Timer0_Init()
    wTimer0_SFR = Timer0_cValue                    ' Load TMR0L\H with the interrupt duration
    Timer0_FlagClear()                              ' Clear Timer0 Interrupt flag
    T0CON0 = %00010000                              ' Prescaler set for 1:1, Timer0 disabled, Timer0 set for 16-bit
    T0CON1 =  %01000000 '%01000000'                ' Timer0 Mode set for FOSC/4, Postscaler set for 1:1, Timer0 not synchronised
    Timer0_Prescaler(Timer0_cPrescalerValue)        ' Set the prescaler for the value used in the Timer0_cPrescalerValue $define
    Timer0_Enable()                                ' Start Timer0
EndProc

/////

ISR_Handler:
    Context Save                                    ' Save compiler system variables and important SFRs used, before performing the interrupt code

    If Timer0_Flag = 1 Then                        ' Was it a Timer0 that triggered the interrupt?
        Toggle LED2_Pin  'LED2_Pin                          ' Yes. So Toggle LED2 pin
        wTimer0_SFR = Timer0_cValue                ' Load TMR0L\H with the interrupt duration
        Timer0_FlagClear()                          ' Clear the Timer0 Interrupt flag
    EndIf

    Context Restore                                ' Restore any variables and SFRs used, then exit the interrupt

RA2(LED2_Pin) constantly light  no have blink!

Pepe


okmn

Main:
    Setup()                                        ' Setup the program and peripherals

    Do                                              ' Create a loop
        Toggle LED2_Pin  ' LED1_Pin
        'Toggle LED1_Pin                        '    Toggle LED1
        DelayMS 100                                ' Delay for a half a second
    Loop 
                                          ' Do it forever
////////////////

Proc Timer0_Init()
    wTimer0_SFR = Timer0_cValue                    ' Load TMR0L\H with the interrupt duration
    Timer0_FlagClear()                              ' Clear Timer0 Interrupt flag
    T0CON0 = %00010000                              ' Prescaler set for 1:1, Timer0 disabled, Timer0 set for 16-bit
    T0CON1 =  %01000000 '%01000000'                ' Timer0 Mode set for FOSC/4, Postscaler set for 1:1, Timer0 not synchronised
    Timer0_Prescaler(Timer0_cPrescalerValue)        ' Set the prescaler for the value used in the Timer0_cPrescalerValue $define
    Timer0_Enable()                                ' Start Timer0
EndProc

//////////////////

ISR_Handler:
    Context Save                                    ' Save compiler system variables and important SFRs used, before performing the interrupt code

    If Timer0_Flag = 1 Then                        ' Was it a Timer0 that triggered the interrupt?
        Toggle LED2_Pin  'LED2_Pin
        Toggle LED1_Pin                          ' Yes. So Toggle LED2 pin
        wTimer0_SFR = Timer0_cValue                ' Load TMR0L\H with the interrupt duration
        Timer0_FlagClear()                          ' Clear the Timer0 Interrupt flag
    EndIf

    Context Restore                                ' Restore any variables and SFRs used, then exit the interrupt


only RA2(LED2_Pin)  gives light, but it is constantly on and does not blink.
RC0(LED1_Pin)  nothing.

okmn


trastikata

Can you try and give me a feedback ... please use PORTA.2 and PORTC.0, otherwise it gets too confusing to follow.

Use this loop and NO ISR eanbled:

    ....
    INTCONbits_GIE = 0

    Do
        Toggle PORTA.2
        Toggle PORTC.0
        DelayMS 1000
    Loop
    ....

Also can you give me feedback to this code with ISR enabled and no toggling in the main code and both LED only in the ISR:

    ....
    Do
        DelayMS 1000
    Loop
   
   
ISR_Handler:
Context Save
    If PIR0bits_TMR0IF = 1 Then   
        PIR0bits_TMR0IF = 0
        TMR0H = $F6
        TMR0L = $3C
        Inc Ten_MilliSeconds
        If Ten_MilliSeconds = 50 Then
            Ten_MilliSeconds = 0
            Toggle PORTA.2
            Toggle PORTC.0
        EndIf           
    EndIf
Context Restore
    ....

trastikata

May I suggest another two tests to run for debug purposes:

1. Instead of HFINTOSC as clock source, use Fosc/4
2. Instead of Timer0 use Timer1

okmn

#50
''****************************************************************
''*  Name    : PIC16F15223_TMR0.BAS                              *
''*  Author  : [select VIEW...EDITOR OPTIONS]                    *
''*  Notice  : Copyright (c) 2024 [select VIEW...EDITOR OPTIONS] *
''*          : All Rights Reserved                              *
''*  Date    : 16.05.2024                                        *
''*  Version : 1.0                                              *
''*  Notes  :                                                  *
''*          :                                                  *
''****************************************************************
'
    Device = 16F15223                          ' Tell the compiler what device to compile for
    Declare Xtal = 32                          ' Tell the compiler what frequency the device is operating at (in MHz)

'--------------------------------------------------------------------------------------------------
' The main program starts here

Main:
Setup()                                    ' Setup the program and peripherals
LATA = 0
LATC = 0
ANSELA = 0
ANSELC = 0
TRISA = 0
TRISC = 0
Symbol Blink_Led_1 = LATA.2
Symbol Blink_Led_2 = LATC.0
Dim Ten_MilliSeconds As Byte = 0
Dim Temporary As Word = 0

   
    INTCONbits_GIE = 0

    Do
        Toggle PORTA.2
        Toggle PORTC.0
        DelayMS 1000
    Loop
   
 
'--------------------------------------------------------------------------------------------------
' Setup the program and peripherals
' Input    : None
' Output    : None
' Notes    : None
'
Proc Setup()
    Osc_Init_32MHz()                            ' Setup the PIC16F15223 to operate with its internal oscillator at 32MHz
'
' Any more setup code needed goes here, before the main program runs.
'
EndProc

'--------------------------------------------------------------------------------------------------
' Setup the PIC16F15223 to operate with its internal oscillator at 32MHz
' Input    : None
' Output    : None
' Notes    : None
'
Proc Osc_Init_32MHz()
    OSCEN = $00
    OSCFRQ = $05                                ' FRQ 32MHz
    OSCTUNE = $00
EndProc

'--------------------------------------------------------------------------------------------------
' Setup the config fuses for the internal 32MHz oscillator

    Config1 FEXTOSC_OFF,_                      ' External Oscillator not enabled
            RSTOSC_HFINTOSC_32MHZ,_            ' HFINTOSC 32MHz
            CLKOUTEN_OFF,_                      ' CLKOUT function is disabled. I/O function on RA4
            VDDAR_LO                            ' VDD Range Analog Calibration Selection bit->Internal analog systems are calibrated For operation between VDD = 1.8V - 3.6V

    Config2 MCLRE_EXTMCLR,_                    ' If LVP = 0, MCLR pin is MCLR. If LVP = 1. RA3 pin function is MCLR
            PWRTS_PWRT_OFF,_                    ' PWRT is disabled
            WDTE_OFF,_                          ' WDT disabled. SEN is ignored
            BOREN_ON,_                          ' Brown-out Reset Enabled. SBOREN bit is ignored
            BORV_LO,_                          ' Brown-out Reset Voltage (VBOR) set to 1.9V
            PPS1WAY_OFF,_                      ' The PPSLOCKED bit can be set and cleared as needed
            STVREN_ON                          ' Stack Overflow or Underflow will cause a reset

    Config4 BBSIZE_BB512,_                      ' 512 words boot block size
            BBEN_OFF,_                          ' Boot Block is disabled
            SAFEN_OFF,_                        ' SAF is disabled
            WRTAPP_OFF,_                        ' Application Block is not write-protected
            WRTB_OFF,_                          ' Boot Block is not write-protected
            WRTC_OFF,_                          ' Configuration Registers are not write-protected
            WRTSAF_OFF,_                        ' Storage Area Flash is not write-protected
            LVP_ON                            ' High Voltage on MCLR/Vpp must be used for programming

    Config5 CP_OFF                              ' User Program Flash Memory code protection is disabled

RC0 blinking
RA2  constant light


Do
        Toggle PORTA.2
        Toggle PORTC.0
        DelayMS 1000
    Loop

/////////////////////////////////


                          ''****************************************************************
''*  Name    : PIC16F15223_TMR0.BAS                              *
''*  Author  : [select VIEW...EDITOR OPTIONS]                    *
''*  Notice  : Copyright (c) 2024 [select VIEW...EDITOR OPTIONS] *
''*          : All Rights Reserved                              *
''*  Date    : 16.05.2024                                        *
''*  Version : 1.0                                              *
''*  Notes  :                                                  *
''*          :                                                  *
''****************************************************************
'
    Device = 16F15223                          ' Tell the compiler what device to compile for
    Declare Xtal = 32                          ' Tell the compiler what frequency the device is operating at (in MHz)

'--------------------------------------------------------------------------------------------------
' The main program starts here
'
On_Hardware_Interrupt GoTo ISR_Handler
Main:
Setup()                                    ' Setup the program and peripherals
LATA = 0
LATC = 0
ANSELA = 0
ANSELC = 0
TRISA = 0
TRISC = 0
Symbol Blink_Led_1 = LATA.2
Symbol Blink_Led_2 = LATC.0
Dim Ten_MilliSeconds As Byte = 0
Dim Temporary As Word = 0

'*****************************************************************************
'TMR0 10ms Interrupt Setting
 TMR0H = $F6
 TMR0L = $3C
 
 T0CON1 = $65 'T0CS HFINTOSC; T0CKPS 1:32; T0ASYNC synchronised; =>Prescaler 1:32
 'TOCON1.7 = Timer0 Clock Source Select Bit 2
 'TOCON1.6 = Timer0 Clock Source Select Bit 1
 'TOCON1.5 = Timer0 Clock Source Select Bit 0
 'TOCON1.4 = TMR0 Input Asynchronization Enable 0:The input to the TMR0 counter is synchronized to Fosc/4
 'TOCON1.3 =  Prescaler Rate Select Bit 3   
 'TOCON1.2 =  Prescaler Rate Select Bit 2
 'TOCON1.1 =  Prescaler Rate Select Bit 1
 'TOCON1.0 =  Prescaler Rate Select Bit 0
 
 
 T0CON0 = $13 'T0OUTPS 1:4; T0EN Disabled; T016BIT 16-bit;=>Postscaler 1:4
 'TOCON0.7 = TMR0 Enable bit
 'TOCON0.6 = --
 'TOCON0.5 = TMR0 Output Read only
 'TOCON0.4 = 16-Bit Timer Operation Select 1:16 bit ; 0:8 bit
 'TOCON0.3 =  TMR0 Output Postscaler (Divider) Select Bit 3
 'TOCON0.2 =  TMR0 Output Postscaler (Divider) Select Bit 2
 'TOCON0.1 =  TMR0 Output Postscaler (Divider) Select Bit 1
 'TOCON0.0 =  TMR0 Output Postscaler (Divider) Select Bit 0

'******************************************************************************
PIR0bits_TMR0IF = 0
INTCONbits_PEIE = 1 'Peripheral Interrupt enabled
INTCONbits_GIE = 1  'Global Interrupt enabled
PIE0bits_TMR0IE = 1 'TMR0 Interrupt enabled
T0CON0Bits_T0EN = 1 'Timer0 Enabled
    Do
    DelayMS 1000
    Loop
   
ISR_Handler:
Context Save
    If PIR0bits_TMR0IF = 1 Then 
        PIR0bits_TMR0IF = 0
        TMR0H = $F6
        TMR0L = $3C
        Inc Ten_MilliSeconds
        If Ten_MilliSeconds = 50 Then
            Ten_MilliSeconds = 0
            Toggle PORTA.2
            Toggle PORTC.0
        EndIf         
    EndIf
Context Restore
 
'--------------------------------------------------------------------------------------------------
' Setup the program and peripherals
' Input    : None
' Output    : None
' Notes    : None
'
Proc Setup()
    Osc_Init_32MHz()                            ' Setup the PIC16F15223 to operate with its internal oscillator at 32MHz
'
' Any more setup code needed goes here, before the main program runs.
'
EndProc

'--------------------------------------------------------------------------------------------------
' Setup the PIC16F15223 to operate with its internal oscillator at 32MHz
' Input    : None
' Output    : None
' Notes    : None
'
Proc Osc_Init_32MHz()
    OSCEN = $00
    OSCFRQ = $05                                ' FRQ 32MHz
    OSCTUNE = $00
EndProc

'--------------------------------------------------------------------------------------------------
' Setup the config fuses for the internal 32MHz oscillator

    Config1 FEXTOSC_OFF,_                      ' External Oscillator not enabled
            RSTOSC_HFINTOSC_32MHZ,_            ' HFINTOSC 32MHz
            CLKOUTEN_OFF,_                      ' CLKOUT function is disabled. I/O function on RA4
            VDDAR_LO                            ' VDD Range Analog Calibration Selection bit->Internal analog systems are calibrated For operation between VDD = 1.8V - 3.6V

    Config2 MCLRE_EXTMCLR,_                    ' If LVP = 0, MCLR pin is MCLR. If LVP = 1. RA3 pin function is MCLR
            PWRTS_PWRT_OFF,_                    ' PWRT is disabled
            WDTE_OFF,_                          ' WDT disabled. SEN is ignored
            BOREN_ON,_                          ' Brown-out Reset Enabled. SBOREN bit is ignored
            BORV_LO,_                          ' Brown-out Reset Voltage (VBOR) set to 1.9V
            PPS1WAY_OFF,_                      ' The PPSLOCKED bit can be set and cleared as needed
            STVREN_ON                          ' Stack Overflow or Underflow will cause a reset

    Config4 BBSIZE_BB512,_                      ' 512 words boot block size
            BBEN_OFF,_                          ' Boot Block is disabled
            SAFEN_OFF,_                        ' SAF is disabled
            WRTAPP_OFF,_                        ' Application Block is not write-protected
            WRTB_OFF,_                          ' Boot Block is not write-protected
            WRTC_OFF,_                          ' Configuration Registers are not write-protected
            WRTSAF_OFF,_                        ' Storage Area Flash is not write-protected
            LVP_ON                            ' High Voltage on MCLR/Vpp must be used for programming

    Config5 CP_OFF                              ' User Program Flash Memory code protection is disabled

RC0  nothing
RA2  nothing


ISR_Handler:
Context Save
    If PIR0bits_TMR0IF = 1 Then
        PIR0bits_TMR0IF = 0
        TMR0H = $F6
        TMR0L = $3C
        Inc Ten_MilliSeconds
        If Ten_MilliSeconds = 50 Then
            Ten_MilliSeconds = 0
            Toggle PORTA.2
            Toggle PORTC.0
        EndIf        
    EndIf
Context Restore

okmn

#51
''****************************************************************
''*  Name    : PIC16F15223_TMR0.BAS                              *
''*  Author  : [select VIEW...EDITOR OPTIONS]                    *
''*  Notice  : Copyright (c) 2024 [select VIEW...EDITOR OPTIONS] *
''*          : All Rights Reserved                               *
''*  Date    : 16.05.2024                                        *
''*  Version : 1.0                                               *
''*  Notes   :                                                   *
''*          :                                                   *
''****************************************************************
'
    Device = 16F15223                           ' Tell the compiler what device to compile for
    Declare Xtal = 32                           ' Tell the compiler what frequency the device is operating at (in MHz)

'--------------------------------------------------------------------------------------------------
' The main program starts here
'
Main:
Setup()                                     ' Setup the program and peripherals
LATA = 0
LATC = 0
ANSELA = 0
ANSELC = 0
TRISA = 0
TRISC = 0
Symbol Blink_Led_1 = LATA.2
Symbol Blink_Led_2 = LATC.0
Dim Ten_MilliSeconds As Byte = 0
Dim Temporary As Word = 0


    Do
    Toggle Blink_Led_2'Every 500ms blink
    Toggle Blink_Led_1'Every 500ms blink
    For Temporary = 0 To 90
        DelayMS 1
    Next Temporary  
    Loop
ISR_Handler:

'--------------------------------------------------------------------------------------------------
' Setup the program and peripherals
' Input     : None
' Output    : None
' Notes     : None
'
Proc Setup()
    Osc_Init_32MHz()                            ' Setup the PIC16F15223 to operate with its internal oscillator at 32MHz
'
' Any more setup code needed goes here, before the main program runs.
'
EndProc

'--------------------------------------------------------------------------------------------------
' Setup the PIC16F15223 to operate with its internal oscillator at 32MHz
' Input     : None
' Output    : None
' Notes     : None
'
Proc Osc_Init_32MHz()
    OSCEN = 0
    OSCFRQ = $05                                ' FRQ 32MHz
    OSCTUNE = $00
EndProc

'--------------------------------------------------------------------------------------------------
' Setup the config fuses for the internal 32MHz oscillator
     '
    Config1 FEXTOSC_OFF,_                       ' External Oscillator not enabled
            RSTOSC_HFINTOSC_32MHZ,_             ' HFINTOSC 32MHz
            CLKOUTEN_OFF,_                      ' CLKOUT function is disabled. I/O function on RA4
            VDDAR_LO                            ' VDD Range Analog Calibration Selection bit->Internal analog systems are calibrated For operation between VDD = 1.8V - 3.6V

    Config2 MCLRE_EXTMCLR,_                     ' If LVP = 0, MCLR pin is MCLR. If LVP = 1. RA3 pin function is MCLR
            PWRTS_PWRT_OFF,_                    ' PWRT is disabled
            WDTE_OFF,_                          ' WDT disabled. SEN is ignored
            BOREN_ON,_                          ' Brown-out Reset Enabled. SBOREN bit is ignored
            BORV_LO,_                           ' Brown-out Reset Voltage (VBOR) set to 1.9V
            PPS1WAY_OFF,_                       ' The PPSLOCKED bit can be set and cleared as needed
            STVREN_ON                           ' Stack Overflow or Underflow will cause a reset

    Config4 BBSIZE_BB512,_                      ' 512 words boot block size
            BBEN_OFF,_                          ' Boot Block is disabled
            SAFEN_OFF,_                         ' SAF is disabled
            WRTAPP_OFF,_                        ' Application Block is not write-protected
            WRTB_OFF,_                          ' Boot Block is not write-protected
            WRTC_OFF,_                          ' Configuration Registers are not write-protected
            WRTSAF_OFF,_                        ' Storage Area Flash is not write-protected
            LVP_ON                             ' High Voltage on MCLR/Vpp must be used for programming

    Config5 CP_OFF                              ' User Program Flash Memory code protection is disabled

RC0  blinking
RA2 blinking


Do
    Toggle Blink_Led_2'Every 500ms blink
    Toggle Blink_Led_1'Every 500ms blink
    For Temporary = 0 To 90
        DelayMS 1
    Next Temporary  
    Loop

okmn

#52
also  this is  blinking two led


Do
        Toggle LATA.2
        Toggle LATC.0
        DelayMS 1000
    Loop



''****************************************************************
''*  Name    : PIC16F15223_TMR0.BAS                              *
''*  Author  : [select VIEW...EDITOR OPTIONS]                    *
''*  Notice  : Copyright (c) 2024 [select VIEW...EDITOR OPTIONS] *
''*          : All Rights Reserved                              *
''*  Date    : 16.05.2024                                        *
''*  Version : 1.0                                              *
''*  Notes  :                                                  *
''*          :                                                  *
''****************************************************************
'
    Device = 16F15223                          ' Tell the compiler what device to compile for
    Declare Xtal = 32                          ' Tell the compiler what frequency the device is operating at (in MHz)

'--------------------------------------------------------------------------------------------------
' The main program starts here

Main:
Setup()                                    ' Setup the program and peripherals
LATA = 0
LATC = 0
ANSELA = 0
ANSELC = 0
TRISA = 0
TRISC = 0
Symbol Blink_Led_1 = LATA.2
Symbol Blink_Led_2 = LATC.0
Dim Ten_MilliSeconds As Byte = 0
Dim Temporary As Word = 0

  
    INTCONbits_GIE = 0

    Do
        Toggle LATA.2
        Toggle LATC.0
        DelayMS 1000
    Loop
  
 
'--------------------------------------------------------------------------------------------------
' Setup the program and peripherals
' Input    : None
' Output    : None
' Notes    : None
'
Proc Setup()
    Osc_Init_32MHz()                            ' Setup the PIC16F15223 to operate with its internal oscillator at 32MHz
'
' Any more setup code needed goes here, before the main program runs.
'
EndProc

'--------------------------------------------------------------------------------------------------
' Setup the PIC16F15223 to operate with its internal oscillator at 32MHz
' Input    : None
' Output    : None
' Notes    : None
'
Proc Osc_Init_32MHz()
    OSCEN = $00
    OSCFRQ = $05                                ' FRQ 32MHz
    OSCTUNE = $00
EndProc

'--------------------------------------------------------------------------------------------------
' Setup the config fuses for the internal 32MHz oscillator

    Config1 FEXTOSC_OFF,_                      ' External Oscillator not enabled
            RSTOSC_HFINTOSC_32MHZ,_            ' HFINTOSC 32MHz
            CLKOUTEN_OFF,_                      ' CLKOUT function is disabled. I/O function on RA4
            VDDAR_LO                            ' VDD Range Analog Calibration Selection bit->Internal analog systems are calibrated For operation between VDD = 1.8V - 3.6V

    Config2 MCLRE_EXTMCLR,_                    ' If LVP = 0, MCLR pin is MCLR. If LVP = 1. RA3 pin function is MCLR
            PWRTS_PWRT_OFF,_                    ' PWRT is disabled
            WDTE_OFF,_                          ' WDT disabled. SEN is ignored
            BOREN_ON,_                          ' Brown-out Reset Enabled. SBOREN bit is ignored
            BORV_LO,_                          ' Brown-out Reset Voltage (VBOR) set to 1.9V
            PPS1WAY_OFF,_                      ' The PPSLOCKED bit can be set and cleared as needed
            STVREN_ON                          ' Stack Overflow or Underflow will cause a reset

    Config4 BBSIZE_BB512,_                      ' 512 words boot block size
            BBEN_OFF,_                          ' Boot Block is disabled
            SAFEN_OFF,_                        ' SAF is disabled
            WRTAPP_OFF,_                        ' Application Block is not write-protected
            WRTB_OFF,_                          ' Boot Block is not write-protected
            WRTC_OFF,_                          ' Configuration Registers are not write-protected
            WRTSAF_OFF,_                        ' Storage Area Flash is not write-protected
            LVP_ON                            ' High Voltage on MCLR/Vpp must be used for programming

    Config5 CP_OFF                              ' User Program Flash Memory code protection is disabled

trastikata

    Do
        Toggle PORTA.2
        Toggle PORTC.0
        DelayMS 1000
    Loop

RC0 blinking
RA2  constant light

    Do
        Toggle LATA.2
        Toggle LATC.0
        DelayMS 1000
    Loop

RC0  blinking
RA2 blinking
[/quote]

It looks like something related to this:

QuoteA write operation to the LATx register has the same effect as a write to the corresponding PORTx register. A read
of the LATx register reads of the values held in the I/O PORT latches, while a read of the PORTx register reads the
actual I/O pin value.

Important: As a general rule, output operations to a port must use the LAT register to avoid Read-
Modify-Write issues. For example, a bit set or clear operation reads the port, modifies the bit, and writes
the result back to the port. When two bit operations are executed in succession, output loading on the
changed bit may delay the change at the output in which case the bit will be misread in the second bit
operation and written to an unexpected level.
The LAT registers are isolated from the port loading and
therefore changes are not delayed.


tumbleweed

Post #37 mentions this:
QuotePin 11 (RA2) logic status no change
it's always 0 (npn transistor "base" pin connecting)
The transistor is also no failure
If you're driving the base of a transistor then reading the PORT to toggle it is likely the issue.

As trastikata points out, toggle the LAT instead.

tumbleweed

Quote from: Pepe on Jun 03, 2024, 04:02 PMI don't understand then why the manual clarifies only 0x0B or 0x8B instead of 0x0B 0x8B 0x10B 0x18B ..... etc (All core registers)
If you look closely at the Core Register table in section 9.2.2 it specifies 'x0Bh or x8Bh' for INTCON, and in this case 'x' means "don't care" (not hex), so it would match ALL register banks.

It's easier to see in section 9.2.6 Device Memory Maps

Pepe

Thanks, I thought 0x referred to hexadecimal.

okmn

the problem is timer0 interrupt issue

we could not see any led blinking still by using timer0 16bit

JonW

Have you tried running a loop and manually waiting for the T0IF to test if this is an int issue?


SETUP TIMER

LOOP_BEGIN:

PRE-LOAD TIMER
CLEAR INT FLAG

FLASH LED'S

WAIT:
TEST FOR T0IF LOOP @ WAIT

GOTO LOOP_BEGIN


This should test timers, Int flags LED's etc

trastikata

Quote from: okmn on Jun 04, 2024, 02:02 PMthe problem is timer0 interrupt issue
we could not see any led blinking still by using timer0 16bit

Did you try:

- 8-bit Timer0
- Fosc/4 instead of HFINTOSC
- Timer1