Part Number: LAUNCHXL-TMS57004
Tool/software: Code Composer Studio
Hello ,
I am trying to use a 10ms timer 3 interrupt. So I have used rtiNotification like I showed below. But my timer is not accurately 10ms. I increase syc3 at every timer3 flag which needs to be every 10 ms and printf a statement when (syc3%900 == 0 ) - which means each 900*10ms = 9 second--. But printf does not operate each 9 second. It becomes 10-11 second.
What may be the problem?
How can I solve that ?
rtiREG1->CMP[3U].COMPx = 100000U;
/** - Setup update compare 3 value. This value is added to the compare 3 value on each compare match. */
rtiREG1->CMP[3U].UDCPx = 100000U;
void rtiNotification(unsigned notification)
{
//printf("\r\n");
if (notification ==1)
{
RTI_TIMEOUT =1;
*INT0_FLAG_ptr = true;
*syc0_ptr = syc0 +1;
}
else if (notification == 2)
{
*INT1_FLAG_ptr = true;
*syc1_ptr = syc1+1;
}
else if (notification == 4)
{
*INT2_FLAG_ptr = true;
*syc2_ptr = syc2 +1;
}
else if (notification == 8)
{
*INT3_FLAG_ptr = true;
*syc3_ptr = syc3 +1;
}
else
{
printf("ERROR \r\n");
}
}
while (1)
{
if ( *INT3_FLAG_ptr == true)
{
int syc_akim;
float toplam_akim=0;
for (syc_akim=0; syc_akim<5; syc_akim++)
{
current = akim [akim_sayac];
toplam_akim= toplam_akim+current;
delay();
}
current =toplam_akim/5.0;
akim_kalan_kapasite = akim_kalan_kapasite - (current*1);
akim_SOC = akim_kalan_kapasite/akim_kapasitesi;
INT3_FLAG = false;
akim_sayac++;
}
if (*INT2_FLAG_ptr == true)
{
INT2_FLAG = false;
}
if ( syc3> 29)
{
printf("%u-----------------------------------------------------------\r\n",akim_sayac);
printf("I:%f\r\nQ:%f\r\nSOC:%f\r\n",current,akim_kalan_kapasite,akim_SOC);
syc3 = 0;
sistem_sayac ++;
}