AUTOSAR MCAL LPCMP example in EB Tresos and coding

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

AUTOSAR MCAL LPCMP example in EB Tresos and coding

Jump to solution
1,823 Views
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 Kudos
Reply
1 Solution
1,772 Views
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

View solution in original post

1 Reply
1,773 Views
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