![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
naughty_mark
Joined: 29 Aug 2012 Posts: 97
|
question about input capture source clock |
Posted: Tue Sep 25, 2012 12:59 am |
|
|
Hi, there
I get a problem when I using input capture.
I am using dsPIC33EP256MU814 and my ccs version is 4.133.
The head of my program is
Code: |
#if defined(__PCD__)
#include <33EP256MU814.h>
#fuses HS,PR,NOWDT,ICSP2,NOGSSK,NOPROTECT,NOAPROTECT,NOAPLK,PR_PLL
#device ADC=12
#use delay(clock=120M, xtal=20M) // Actual crystal is 20M
#pin_select U1TX = PIN_D0
#pin_select U1RX = PIN_D1
#pin_select U2TX = PIN_D2
#pin_select U2RX = PIN_D3
#use RS232(UART1, STREAM = GSM, BAUD=9600, XMIT = PIN_D0 , RCV = PIN_D1 , BITS = 8, STOP = 1, PARITY = N, ERRORS)
#use RS232(UART2, STREAM = MODBUS, BAUD=9600, XMIT = PIN_D2 , RCV = PIN_D3 , BITS = 8, STOP = 1, PARITY = N, ERRORS)
#use i2c(MASTER, I2C1,SCL = PIN_D10, SDA = PIN_D9 , FORCE_SW)
#pin_select IC1=PIN_F0
#pin_select C1TX = PIN_D6
#pin_select C1RX = PIN_D5
#endif
|
And I init my IC1 in they way following, I don't use ccs built-in function because it doesn't work.
Code: |
void iniIC1(void)
{
SETUP_TIMER2(TMR_INTERNAL,TMR_DIV_BY_64); //enable Timer 2
/*ini IC interrupt config*/
IC1CON1 = 0x0403;
IC1CON2 = 0x0000;
IFS0 = 0x0000;
IEC0 |= 0x0002;
IPC0 |= 0x0010;
}
|
The problem is even if I declare DIV_BY_64 for timer2, the frequency which driver the IC timer is system clock (120M/2 = 60M).
The setup_timer2 built-in function works, because I used the same built-in function for other timers and works well. I can not get where is the cause.
I tried many ways including "cascade ic" to get a 32bit timer, but failed. Anyone can give some suggestion ?
Thanks a lot |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19359
|
|
Posted: Tue Sep 25, 2012 4:20 am |
|
|
Code: |
SETUP_TIMER2(TMR_INTERNAL|TMR_DIV_BY_64); //enable Timer 2
|
SETUP_TIMERx, does not accept multiple arguments. It expects the constants to be or'ed together.
Quote from the .h file:
"
// Constants used for SETUP_TIMERx() are:
// (or (via |) together constants from each group)"
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
naughty_mark
Joined: 29 Aug 2012 Posts: 97
|
|
Posted: Tue Sep 25, 2012 4:18 pm |
|
|
Ttelmah wrote: | Code: |
SETUP_TIMER2(TMR_INTERNAL|TMR_DIV_BY_64); //enable Timer 2
|
SETUP_TIMERx, does not accept multiple arguments. It expects the constants to be or'ed together.
Quote from the .h file:
"
// Constants used for SETUP_TIMERx() are:
// (or (via |) together constants from each group)"
Best Wishes |
Hi Ttelmah, I would like to say thank you very much, and how stupid I am I used other timer in a correct way but this. ![Shocked](images/smiles/icon_eek.gif) |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19359
|
|
Posted: Wed Sep 26, 2012 1:23 am |
|
|
It is made harder, with things like the PWM function, supporting an overloaded version with two variables, _or_ the values or'ed together, while others require only the later. Easy to forget/miss.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|