Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Freescale MCF5213 _DMA Timer_PWM time period calculation problem

Status
Not open for further replies.

ilamseeker

Member level 1
Member level 1
Joined
Apr 7, 2006
Messages
41
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Visit site
Activity points
1,720
Dear All,



I am using two MCF5213 Evaluation kits: one for generating the PWM waveform and the other for checking the period of the generated PWM waveform.



I am using he DMA timers to check the time period of the pulse. I have configured it but it is giving incorrect value in the DTCR(counter) register.



I am using DTIN1 pin for giving the pulse input which has the period of 0.8ms but the value in the counter turns out to be 264244026.



which gives 264244026/(80 * 10^6) = 3.303050325 which is incorrect. Please check the code and let me know if i am doing something wrong here



thanks





I am using the following code:



int main(void)

{





// Enable the directions pins TC[1]

MCF_GPIO_PTCPAR = 0

| MCF_GPIO_PTCPAR_DTIN0_DTIN0

| MCF_GPIO_PTCPAR_DTIN1_DTIN1

| MCF_GPIO_PTCPAR_DTIN2_DTIN2

| MCF_GPIO_PTCPAR_DTIN3_DTIN3;



MCF_DTIM_DTMR(1) =

MCF_DTIM_DTMR_PS(0x00)

| MCF_DTIM_DTMR_CE_RISE

| MCF_DTIM_DTMR_CLK_DIV1

| MCF_DTIM_DTMR_RST;



//Setup the interrupt registers for DTIN[1] & DTIN[3]

MCF_INTC_IMRL &= ~MCF_INTC_IMRL_MASKALL

& ~MCF_INTC_IMRL_INT_MASK20

& ~MCF_INTC_IMRL_INT_MASK22;

MCF_INTC_ICR(20) = MCF_INTC_ICR_IP(4) | MCF_INTC_ICR_IL(4);

mcf5xxx_set_handler(64 + 20, direction12_handler);

mcf5xxx_irq_enable();



while (1)

{

printf("the value of the counter is %d \n", counter);

}







}



__declspec(interrupt) void direction12_handler(void) {



counter = (long int) MCF_DTIM_DTCR(1); //Read the encoder counter



MCF_DTIM_DTCN(1) = 0; //Reset the encorder counter



MCF_DTIM_DTER(1) |= MCF_DTIM_DTER_CAP;

}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top