AUTOSAR MCAL LPCMP example in EB Tresos and coding

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

AUTOSAR MCAL LPCMP example in EB Tresos and coding

跳至解决方案
1,817 次查看
emerging
Contributor III

I have a few queries on the sample "S32K344_LPCMP_Wkup_S32DS_3_4_RTD_MCAL_2_0.  get from NXP 

My usecase is just to compare an analog voltage with a reference voltage and get the comparator output.
For my application can i remove the first three channels IcuChannel_EVB, IcuChannel_WB, IcuChannel_LPCMP_Wkup from configurator and keep only IcuChannel_LPCMP1 in configurator, Will that work because i need only a comparator.
When i come to coding part i am not able to see any section in main.c that checking the status of comparator. Don't we need any functionality to check the comparator status like Cmp_Ip_GetStatus(). In code i was not able to find the part where it checking comparator status
Could you kindly provide your opinion on the queries I mentioned above? 

0 项奖励
回复
1 解答
1,766 次查看
DanNguyenDuy
NXP Employee
NXP Employee

Hello @emerging,

You can see the RRCR1[RR_CH1EN] = 1 and the  CCR0[CMP_EN] = 1
after invoking the Icu_EnableEdgeDetection(IcuChannel_LPCMP1) function to enable  Round-Robin Trigger mode in LPCMP. In this mode, a trigger event initiates a comparison sequence; and RTC is configured in this example to trigger CMP performing a DAC compare. If the DAC value is greater than the DAC_DATA value then status flags will be set.

Besides, this function also sets the IER[RRF_IE] bit, following the S32K3XX Reference manual: "If IER[RRF_IE] sets, an asynchronous interrupt asserts". when CSR[RRF] is set after detecting when any channel's last comparison result is different from the pre-set value in Trigger mode, it will route to WKPU.

Calling Icu_EnableEdgeDetection(IcuChannel_LPCMP_Wkup); function to configure WKUP registers can receive wakeup trigger from LPCMP (when RRF was set).

nxf78987_1-1710834163714.png

Cmp_Ip_GetStatus() is not necessary use in this example because the comparator status flags will route to WKUP.

Best regards,

Dan

在原帖中查看解决方案

1 回复
1,767 次查看
DanNguyenDuy
NXP Employee
NXP Employee

Hello @emerging,

You can see the RRCR1[RR_CH1EN] = 1 and the  CCR0[CMP_EN] = 1
after invoking the Icu_EnableEdgeDetection(IcuChannel_LPCMP1) function to enable  Round-Robin Trigger mode in LPCMP. In this mode, a trigger event initiates a comparison sequence; and RTC is configured in this example to trigger CMP performing a DAC compare. If the DAC value is greater than the DAC_DATA value then status flags will be set.

Besides, this function also sets the IER[RRF_IE] bit, following the S32K3XX Reference manual: "If IER[RRF_IE] sets, an asynchronous interrupt asserts". when CSR[RRF] is set after detecting when any channel's last comparison result is different from the pre-set value in Trigger mode, it will route to WKPU.

Calling Icu_EnableEdgeDetection(IcuChannel_LPCMP_Wkup); function to configure WKUP registers can receive wakeup trigger from LPCMP (when RRF was set).

nxf78987_1-1710834163714.png

Cmp_Ip_GetStatus() is not necessary use in this example because the comparator status flags will route to WKUP.

Best regards,

Dan