CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PIC16F15325: Timer 2 reset pin T2IN re-map

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Momboz



Joined: 03 Jun 2009
Posts: 29

View user's profile Send private message

PIC16F15325: Timer 2 reset pin T2IN re-map
PostPosted: Fri Feb 28, 2020 9:35 am     Reply with quote

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.
temtronic



Joined: 01 Jul 2010
Posts: 9176
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Feb 28, 2020 9:54 am     Reply with quote

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
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Feb 28, 2020 2:22 pm     Reply with quote

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.
jeremiah



Joined: 20 Jul 2010
Posts: 1329

View user's profile Send private message

PostPosted: Fri Feb 28, 2020 2:52 pm     Reply with quote

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
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19375

View user's profile Send private message

PostPosted: Sat Feb 29, 2020 1:41 am     Reply with quote

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.
Momboz



Joined: 03 Jun 2009
Posts: 29

View user's profile Send private message

PostPosted: Sun Mar 01, 2020 10:58 am     Reply with quote

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.
temtronic



Joined: 01 Jul 2010
Posts: 9176
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Mar 01, 2020 3:43 pm     Reply with quote

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 !
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Mar 01, 2020 6:02 pm     Reply with quote

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.
Ttelmah



Joined: 11 Mar 2010
Posts: 19375

View user's profile Send private message

PostPosted: Sun Mar 01, 2020 11:02 pm     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group