Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

PSoC™ 4 Forum Discussions

David_Zhang
Level 5
Level 5
100 replies posted First solution authored 50 replies posted

Dear  Infineon:
      due to  in some application we need to keep the ILO frequency , We note datesheet  describle that API can improve the ILO accuracy, We see the code of CE210292_WatchDogTimer, but we don't down how to do it ;

     we design the code ,   we don't know where  is mistake of code , can you help to advice it . TKS;

uint32 iloMatchCounts=0x00;

#define WAKEUP_PERIOD_IN_MS 500u
#define DESIRED_DELAY 500000u
#define ILO_MATCH_COUNTS ((WAKEUP_PERIOD_IN_MS * CY_SYS_CLK_ILO_DESIRED_FREQ_HZ)/ 1000)

uint32 iloMatchCounts = ILO_MATCH_COUNTS;

//开始测量
CySysClkIloStartMeasurement();

CySysWdtWriteMatch(CySysWdtReadMatch() + iloMatchCounts);
//补偿ILO的值;
if(CYRET_SUCCESS == CySysClkIloCompensate(DESIRED_DELAY, &tempIloCounts))
{
iloMatchCounts = (uint32)tempIloCounts;
}

// 写值到WDT>>这个需要吗?
CySysWdtWriteMatch(CySysWdtReadMatch() + iloMatchCounts);

//读取WDTCount
count1 = CySysWdtReadCount();
CY_delay();
count2 = CySysWdtReadCount();

//算误差;
count0 = Count2-cunt1;

CySysClkIloStopMeasurement();

 

0 Likes
1 Solution
LinglingG_46
Moderator
Moderator
Moderator
10 questions asked 5 questions asked 250 sign-ins

CySysClkIloCompensate() 的校准原理是在 IMO精准时钟下开辟一个 1ms 的时间窗,然后在这 1ms 里对 ILO 进行计数测量,然后根据函数中的两个测试参数,
把某个固定时间里ILO的总周期数给计算出来,供用户设置 WDT 使用。

不需要你自己计算了。也就是你写的这一段是不需要的:

// 写值到WDT>>这个需要吗?
CySysWdtWriteMatch(CySysWdtReadMatch() + iloMatchCounts);

//读取WDTCount
count1 = CySysWdtReadCount();
CY_delay();
count2 = CySysWdtReadCount();

//算误差;
count0 = Count2-cunt1;

View solution in original post

0 Likes
3 Replies
LinglingG_46
Moderator
Moderator
Moderator
10 questions asked 5 questions asked 250 sign-ins

CySysClkIloCompensate() 的校准原理是在 IMO精准时钟下开辟一个 1ms 的时间窗,然后在这 1ms 里对 ILO 进行计数测量,然后根据函数中的两个测试参数,
把某个固定时间里ILO的总周期数给计算出来,供用户设置 WDT 使用。

不需要你自己计算了。也就是你写的这一段是不需要的:

// 写值到WDT>>这个需要吗?
CySysWdtWriteMatch(CySysWdtReadMatch() + iloMatchCounts);

//读取WDTCount
count1 = CySysWdtReadCount();
CY_delay();
count2 = CySysWdtReadCount();

//算误差;
count0 = Count2-cunt1;

0 Likes
David_Zhang
Level 5
Level 5
100 replies posted First solution authored 50 replies posted

HI   Infineon:

    CySysClkIloCompensate(DESIRED_DELAY, &tempIloCounts));  该函数中的DESIRED_DELAY 中范围是有什么标准吗? 只要uint32 的范围就可以吗? 例子用的是#define DESIRED_DELAY 500000u

0 Likes

理论上是这样的,但是你填到最大值也没有用啊。

/* WDT match value is updated in order to obtain periodic interrupts */
CySysWdtWriteMatch(CySysWdtReadMatch() + iloMatchCounts);

你也不能超过wdt的窗口时间,不然你这个数应该是没什么意义。这个矫正,就是为了让这个iloMatchCounts更加趋近于你想要的delay的时间。

0 Likes