"Icu_GetDutyCycleValues()" doesn't read Period from register, when EMIOS0_CH2 cfged with counter-F

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

"Icu_GetDutyCycleValues()" doesn't read Period from register, when EMIOS0_CH2 cfged with counter-F

1,347 Views
sumitmassey
Contributor II

I have configured 2 channels, EMIOS0_2 and EMIOS0_15 for capturing time period to measure PWM frequency.

#Configuration using Davinci Configurator:
EMIOS0_channel-2 --> configured to use bus counter F --> when values are read using "Icu_GetDutyCycleValues()" --> the API skips reading when overflow bit is set in Status register S2.

EMIOS0_channel-15 --> configured to use bus counter F --> when values are read using "Icu_GetDutyCycleValues()" --> the API doesn't skip and reads the value (since overflow bit is invalid for Channel-15).

#reading values:
// clear before reading
channel_2.ActiveTime = 0u;
channel_2.PeriodTime = 0u;
Icu_GetDutyCycleValues(..);

// clear before reading
channel_15.ActiveTime = 0u;
channel_15.PeriodTime = 0u;
Icu_GetDutyCycleValues(..);


# Few questions:
1) Why the overflow bit is set in Status register S2, when channel-2 is configured to use counter F?
2) Why there's a check for overflow bit in Icu_GetDutyCycleValues(..), when there can be some channel like Channel-2 which might be configured not to use internal counter?

11 Replies

1,282 Views
nxf78987
NXP Employee
NXP Employee

Hi @sumitmassey,

What is the package's name and derivative's name you are using? (for example: SW32K3_RTD_4.4_2.0.0 is the package's name and S32K344 is a derivative's name)

Could you send me your configuration files?

Best regards,

Dan

0 Kudos

1,268 Views
sumitmassey
Contributor II

Hi @nxf78987,

I'm using "SW32K3_RTD_4.4_2.0.0" and "S32K324" derivative.
I have to see if I can share the configuration files.

Regards,
Sumit

0 Kudos

1,219 Views
nxf78987
NXP Employee
NXP Employee

Hello @sumitmassey,

1) Why the overflow bit is set in Status register S2, when channel-2 is configured to use counter F?

=> Because overflow has occurred in counter F. In my opinion, this means indicated that you didn't capture any pulse before.

2) Why there's a check for overflow bit in Icu_GetDutyCycleValues(..), when there can be some channel like Channel-2 which might be configured not to use an internal counter?

=> From my point of view, the Icu_GetOverflow didn't regard to use of an internal counter or not because Icu_GetOverflow indicates the overflow status for a specific channel.

If you enable "IcuOverflowNotificationApi" then the Icu_GetOverflow will isn't called in the Icu_GetDutyCycleValues() function.

3. I guess that you didn't enable EMIOS to interrupt and you can't get period and duty. So, in this situation, to get the duty and period, you must enable EMIOS interrupt. When the EMIOS interrupt function occurs, it will be updated values into a global variable in RTD driver to save period and duty. Because ICU_MODE_SIGNAL_MEASUREMENT can't install a callback function. So, in the main function, you need to call Icu_GetDutyCycleValues() function as below to get those values:

do
        {
            Icu_GetDutyCycleValues(0, &ReadValueCh0[u8Notification]);
        } while ((0u == ReadValueCh0[u8Notification].ActiveTime) && (0u == ReadValueCh0[u8Notification].PeriodTime));
 
I attached an example.
 
Best regards,
Dan
0 Kudos

1,168 Views
sumitmassey
Contributor II

Hi @nxf78987 ,

1/2)
But according to the data sheet, "Status register S2" only stores the status of the internal counter, and I have configured channel-2 to use the Bus Counter-F not the internal counter.

Even if it overflows (lets say), then it should over flow for Channel-15 as well but it doesnt. Because MCAL implementation of the "Icu_GetDutyCycleValues()" function is such that, it calls "Icu_GetOverflow()" and based on its results it read the "ActiveTime" and "PeriodTime" to my local parameters

This Icu_GetOverflow() function checks overflow bit in S-register like "((eMIOS_S_OVFL_MASK == (u32RegCSR & eMIOS_S_OVFL_MASK))", and skips reading for Channel-2 but not for Channel-15, though they are configured to use the same Bus Counter-F.

So my issue is:
For Channel-2 --> Overflow bit is set in Status register
For Channel-15 --> Overflow bit is not set in Status register
Even though both of the channels are configured to use the same Bus counter-F.

Important to note:
- In section 62.8.6.8 (UC Counter n (CNT0 - CNT23)" of the datasheet: It states that UC internal counter is used only in the mentioned modes and I'm using using IPWM mode which
doesn't use UC internal counter.

Snapshot from datasheet below:

UC_internal_counter.PNG


- For EMIOS_0_channel_15, internal counter is not supported thats why the value of Status register S15 becomes invalid for "Icu_GetOverflow()", and thus reads the values properly for Channel-15.
That's why I asked my question-(2), Icu_GetOverflow() will not work similar for the Channel-15.

- Global counter bus F driven by UC22.

3) Emios interrupt is enabled, that's why I'm able to get the values on Channel-15 properly.
But for Channel-2 it reads values when the Overflow bit is not set in Status register S2, otherwise when its set it doesn't read.

1,104 Views
nxf78987
NXP Employee
NXP Employee

Hello @sumitmassey.,

For Channel-2 --> Overflow bit is set in Status register
For Channel-15 --> Overflow bit is not set in Status register
Even though both of the channels are configured to use the same Bus counter-F.

=> First, you can see that channel 15 didn't support for Overflow bit as the below image. So, you saw that "Overflow bit is not set in Status register" of channel 15.

nxf78987_0-1687136703319.png

=> The second, in the reference manual was noted that:

nxf78987_1-1687137447647.png

So, in IPWM mode, CNT[2] and CNT[15] was used as a timebase to count input events.

=> Third, I tested with 2 situation (the interrupt enabled):

Situation 1: Only use channel 2 then overflow bit didn't set.

Situation 2: Use both Channel 2 and channel 15 then overflow bit was set on channel 2.

In this situation, I propose that this bit was set because the interrupt of channel 2 was pending while interrupt of channel 15 occur.

Best regards,

Dan

0 Kudos

1,089 Views
sumitmassey
Contributor II

Hi @nxf78987 

Thank you for the explanation, but what would be the behavior of "Icu_GetOverflow()" then?
Will it be same for both the channels 2 and 15??

Regards,
Sumit

0 Kudos

1,082 Views
nxf78987
NXP Employee
NXP Employee

Hello @sumitmassey,

The behavior of "Icu_GetOverflow() is checking OVFL bit of UC channel status register specific. But channel 15 don't have this bit and this function always return FALSE for channel 15; but channel 2 has the OVFL bit and this bit will be checked and return the correct value (TRUE or FALSE).

Best regards,

Dan

0 Kudos

1,077 Views
sumitmassey
Contributor II

Hi @nxf78987 ,

That's true for the "Icu_GetOverflow()", so now based on this behaviour of overflow bit check, Icu_GetDutyCycleValues() api will read period values for one channel-15 (all the time even if it overflows) and not for other channel-2 (i.e. it will read all the time except when it overflows).

Regards,
Sumit

0 Kudos

1,074 Views
nxf78987
NXP Employee
NXP Employee

Hello @sumitmassey,

That's correct.

Best regards,

Dan

0 Kudos

1,057 Views
sumitmassey
Contributor II

Hi @nxf78987 ,

So to solve this issue and get the continuous read values on both the channels, I shall enable the option "GetOverflownotification" and this will disable the getoverflowbit check, and read continuoisly?
There's no other solution for now, right?


Best Regards,
Sumit

0 Kudos

1,033 Views
nxf78987
NXP Employee
NXP Employee

Hello @sumitmassey,

That's right.

Best regards,

Dan

0 Kudos