View previous topic :: View next topic |
Author |
Message |
bdeb
Joined: 05 Nov 2010 Posts: 42 Location: Sweden
|
CCP1 and Timer3 on 16F183xx |
Posted: Sat Aug 07, 2021 5:06 am |
|
|
Compiler: 5.075
IDE: MPLAB-X 5.45
PIC: 16F18325
Dear gurus, once again I seek your help.
Manual says you may use TMR0/1/3/5 for CCP1, but the only constants I find in 16F18325.h are #define CCP_TIMER2/4/6 which are for PWM only according to me.
Things work if I set CCP1CON=0b10000101 and CCPTMRS=0b00000010 directly to regs, but not via setup_ccp1()
Since I often change uP types during development, I try to use CCS functions if possible.
Have I missed something here?
All the best:
/Björn |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Sat Aug 07, 2021 7:41 am |
|
|
They are not for 'PWM only'.
This is a classic problem of CCS choosing names that are not really very
informative.
The setting for Timer4 when using the PWM, is exactly the same bits as
the setting for Timer3 when using the CCP. Similarly the setting for
Timer6 when using the PWM, is exactly the same bits as the setting for
Timer5 when using the CCP.
You can just use CCP_TIMER4 to use timer3 with the CCP and CCP_TIMER6
to use Timer5.
Obviously the associated timer has to be set to EXTERNAL_SYNC.
Sometimes the CCS 'choice of names', is really silly. |
|
|
bdeb
Joined: 05 Nov 2010 Posts: 42 Location: Sweden
|
|
Posted: Sat Aug 07, 2021 7:52 am |
|
|
D'oh!!
Should have spotted that myself while fiddling with the bits..
Since it had become 5:30 in the AM, I was probably happy to get it going..
Thank you Ttelmah for explaining!
All the best:
/Björn |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Sat Aug 07, 2021 10:35 am |
|
|
I suggest you suggest to CCS that a name like PWM_TIMER4_CCP_TIMER3
would be much more sensible. |
|
|
bdeb
Joined: 05 Nov 2010 Posts: 42 Location: Sweden
|
|
Posted: Sat Aug 07, 2021 10:55 am |
|
|
Spot on!
Even typing *that* would take shorter time than what I´ve spent saying unprintable words to my computer!
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Sun Aug 08, 2021 10:08 am |
|
|
Been there. Got the 'T' shirt....
I call it, "wall, head, impact technology testing". |
|
|
bdeb
Joined: 05 Nov 2010 Posts: 42 Location: Sweden
|
|
Posted: Sun Aug 08, 2021 11:52 am |
|
|
Aha! The old WHITT-syndrom!
If politicians where replaced by engineers - global peace && understanding would happen in 4 clock cycles.. |
|
|
pmuldoon
Joined: 26 Sep 2003 Posts: 218 Location: Northern Indiana
|
|
Posted: Wed Sep 08, 2021 8:54 am |
|
|
This thread needs to be saved in the archives, lol! |
|
|
|