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 CCS Technical Support

question about input capture source clock

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



Joined: 29 Aug 2012
Posts: 97

View user's profile Send private message

question about input capture source clock
PostPosted: Tue Sep 25, 2012 12:59 am     Reply with quote

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
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Tue Sep 25, 2012 4:20 am     Reply with quote

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
naughty_mark



Joined: 29 Aug 2012
Posts: 97

View user's profile Send private message

PostPosted: Tue Sep 25, 2012 4:18 pm     Reply with quote

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 Confused I used other timer in a correct way but this. Shocked
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Wed Sep 26, 2012 1:23 am     Reply with quote

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. Very Happy

Best Wishes
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