AUTOSAR MCAL LPCMP example in EB Tresos and coding

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

AUTOSAR MCAL LPCMP example in EB Tresos and coding

ソリューションへジャンプ
1,818件の閲覧回数
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,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

元の投稿で解決策を見る

1 返信
1,768件の閲覧回数
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