S12zvca 16bit timer

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

S12zvca 16bit timer

720 次查看
shubhangi_mahaj
Contributor I

Hello all,

Currently I am exploring VLG-S12zvca evaluation board. Working on 16bit timer.

I have written a small code where I am toggling GPIO pin PP6 and varying its on and off timing by using 16 bit timer, I have set ECLK to 24 MHz. i have observed following observations and Also please find attached doc for reference.

Questions:-

1) if we increment timer counter to maximum value that is 65535 and set prescalar value to 0 , it generates 2.73msec of delay, observed at ppg, it matched with calculations as mentioned below -->

Delay time = Counter value/ Eclk/2^ prescalar value

                  = 65535/24/2^0 * 10^-6

                  = 65535/24 us

                  =2730.625 us

                  =2.73ms

  I want to know that , how much minimum delay can be generated using minimum counter value ?

2) I have checked for counter value 1,2,3,4,5 it consider as 65535 and generates 2.73msec of delay it doesn't matches with calculations o, instead I have observed 1us of delay at counter value of 6, why is it?

Sr.no.ON time Value Off time valueObserved ON time ValueObserved Off time ValueCalculated on(us)Calculated off(us)
165535655352.8ms2.8ms2730.6252730.625
21000065535420us2.76ms416.66666672730.625
31655352.76ms2.76ms0.0416666672730.625
42655352.76ms2.76ms0.0833333332730.625
53655352.76ms2.76ms0.1252730.625
64655352.76ms2.76ms0.1666666672730.625
75655352.76ms2.76ms0.2083333332730.625
8661us1us0.250.25

--> Does it mean that S12zvca internally takes 24cycles for its compiling, boot loading or any other tasks that's why it supports only 1us at counter value 6?

-->is it possible to generate a delay in nanosecond by using s12zvca ? if yes then how?

Also Find code below;-

#include <hidef.h> /* for EnableInterrupts macro */

#include "derivative.h" /* include peripheral declarations */

void main(void) {

CPMUCLKS_PLLSEL = 1;

CPMUREFDIV_REFFRQ = 1; 

CPMUREFDIV_REFDIV = 0x0;

CPMUSYNR_VCOFRQ = 0x1;

CPMUSYNR_SYNDIV = 0x5;

CPMUPOSTDIV_POSTDIV = 0x0;

CPMUOSC_OSCE = 1;

while(!CPMUIFLG_LOCK){}

CPMUIFLG = 0xFF;

ECLKCTL_NECLK=0;

  //Use PP6 as output for LED

DDRP_DDRP6 = 1;

TIM0TSCR1 = 0x90;

TIM0TSCR2 = 0x10;

TIM0TIOS_IOS0=1;

for(;;){

PTP_PTP6=1;

TIM0TC0 = TIM0TCNT + 65535 ; /* start an OC0 operation_300ms */

while(!(TIM0TFLG1 & 0x01)); /* wait for PT0 to go high */

PTP_PTP6=0;

TIM0TC0 = TIM0TCNT + 65535 ; /* start an OC0 operation_300ms */

while(!(TIM0TFLG1 & 0x01)); /* wait for PT0 to go high */

}

}

Please let me know your all valuable comments and suggestion.

Thank You,

Shubhangi Mahajan

标签 (1)
0 项奖励
回复
1 回复

613 次查看
danielmartynek
NXP TechSupport
NXP TechSupport

Hello,

It has been already answered here:

https://community.nxp.com/thread/502737 

BR, Daniel

0 项奖励
回复