View previous topic :: View next topic |
Author |
Message |
Momboz
Joined: 03 Jun 2009 Posts: 29
|
PIC16F15325: Timer 2 reset pin T2IN re-map |
Posted: Fri Feb 28, 2020 9:35 am |
|
|
I would like to use the T2IN pin to reset the timer 2.
I have the following code lines:
Code: | #pin_select T2IN = PIN_A4
setup_timer_2(T2_DIV_BY_128|T2_CLK_INTERNAL|T2_RESET_ON_RE|T2_RESET_FROM_T2IN,30,1); //36.0 us overflow, 396 us interrupt
|
I am not sure whether I did understand things correctly, but I can't find out the function name for this T2IN.
My compiler version (5.078) doesn't know about this function name for T2IN.
Any help?
Thanks. |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9176 Location: Greensville,Ontario
|
|
Posted: Fri Feb 28, 2020 9:54 am |
|
|
I don't have that PIC and a new compiler but I'd look in the processor header file, find the section for 'timer2' and see what CCS calls it. Microchip datasheet, page 312, register 27-4 says T2INPPS.
Others with a newer compiler that supports that chip can help.
Rethinking this, it should be possible to just set/clear the appropriate bits in the various timer registers to get the required configuration you need...
Last edited by temtronic on Fri Feb 28, 2020 3:24 pm; edited 1 time in total |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Feb 28, 2020 2:22 pm |
|
|
It's not supported by the latest version (5.093) either. I think it's an
oversight by CCS. If you own the compiler, you can email CCS support
and ask if they can fix it. They may be able to send you a new DLL file.
But only if you own the compiler. |
|
![](templates/subSilver/images/spacer.gif) |
jeremiah
Joined: 20 Jul 2010 Posts: 1329
|
|
Posted: Fri Feb 28, 2020 2:52 pm |
|
|
Since there appears to be only one T2 PPS option, you might try the normal T2CK and see if that works. It compiles for me, but I don't have a way to test it and I am not familiar enough with the 16's to see if the assembly is correct in a short amount of time:
Code: |
#include <16F15325.h>
#pin_select T2CK = PIN_A4
void main()
{
setup_timer_2(T2_DIV_BY_128|T2_CLK_INTERNAL|T2_RESET_ON_RE|T2_RESET_FROM_T2IN,30,1); //36.0 us overflow, 396 us interrupt
}
|
|
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19375
|
|
Posted: Sat Feb 29, 2020 1:41 am |
|
|
The MicroChip pin naming for this is appalling.
If you look, they have the clock selection in Fig 27-2 choosing the 'clock
source', but the same selection is used in the reset setup to choose the
reset source. Not surprising then that the CCS labeling is a bit unclear....
The distinction between the two modes for the signal is done by the
T2RST register.
Now it is not clear from your description exactly what mode you want the
timer to run in. I suspect free running, just with a rising edge reset?.
If so, this is what Jeremiah has posted. |
|
![](templates/subSilver/images/spacer.gif) |
Momboz
Joined: 03 Jun 2009 Posts: 29
|
|
Posted: Sun Mar 01, 2020 10:58 am |
|
|
temtronic wrote: | I don't have that PIC and a new compiler but I'd look in the processor header file, find the section for 'timer2' and see what CCS calls it. Microchip datasheet, page 312, register 27-4 says T2INPPS.
Others with a newer compiler that supports that chip can help.
Rethinking this, it should be possible to just set/clear the appropriate bits in the various timer registers to get the required configuration you need... |
I tried this naming and no success.
Thank you. |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9176 Location: Greensville,Ontario
|
|
Posted: Sun Mar 01, 2020 3:43 pm |
|
|
T2INPPS IS the default selection of that regisiter, so providing the 'pin select' code works, then PIN_A4 should reset the timer. Now you need to check IF A4 can be 'pin selected' though.
Again, I don't use that PIC and my compiler's too old to cut code and see the assembler.
Just looked at the PPS chapter... seems RA4 is the default for T1G, so if you 'remap' RA4 you'll also have to 'remap' the T1G function to another pin ! |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Mar 01, 2020 6:02 pm |
|
|
jeremiah wrote: | Since there appears to be only one T2 PPS option, you might try the normal T2CK and see if that works. It compiles for me, but I don't have a way to test it and I am not familiar enough with the 16's to see if the assembly is correct in a short amount of time:
Code: |
#include <16F15325.h>
#pin_select T2CK = PIN_A4
void main()
{
setup_timer_2(T2_DIV_BY_128|T2_CLK_INTERNAL|T2_RESET_ON_RE|T2_RESET_FROM_T2IN,30,1); //36.0 us overflow, 396 us interrupt
}
|
|
I looked at the .LST file for the PPS code for CCS vs. 5.093, and it looks correct:
Code: |
.................... void main(void)
0003: MOVLW 55
0004: MOVLB 3D
0005: MOVWF PPSLOCK
0006: MOVLW AA
0007: MOVWF PPSLOCK
0008: BCF PPSLOCK.PPSLOCKED
0009: MOVLW 04 // Pin A4
000A: MOVWF T2INPPS
000B: MOVLW 55
000C: MOVWF PPSLOCK
000D: MOVLW AA
000E: MOVWF PPSLOCK
000F: BSF PPSLOCK.PPSLOCKED
|
Momboz, I suggest that you try Jeremiah's code. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19375
|
|
Posted: Sun Mar 01, 2020 11:02 pm |
|
|
I too had already done this.
If you look at the data sheet, there is only one PPS source for this
and what it is used for is changed by the T2RST register.
What Jeremiah posted should work. |
|
![](templates/subSilver/images/spacer.gif) |
|