S32K312 BCTU FIFO/loop switch (non AUTOSAR prj)

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

S32K312 BCTU FIFO/loop switch (non AUTOSAR prj)

1,021 Views
Drifter22
Contributor II

Hello,

I've read so many posts regarding BCTU topic and examples too, but I'm a bit confused about best configuration for my purpose.

Into my project I have 2 system statuses:

1- (DC brushed motor PWM active) ADC acquisitions triggered by Emios_1_12 PWM in order to read motor current and other channels synchronized with PWM frequency (and duty)

2- (no actuation) I'd like to acquire same channels from ADC continously without interruptions and then I'll read via SW only the channel that I need for a particular task.

My analysis:

Mode 1: BCTU HW triggered and list with all needed channels

Mode 2: BCTU triggered started once via SW and with loop mode active, in order to let conversions run continously.

I need to switch between these two modes (by disabling HW trigger or stopping loop mode), so I'd like to know which is the best solution and maybe alternatives.

My question is related also to which destination to use for results: for mode 2 I'd use ADC registers and then read with Adc_Sar_Ip_GetConvResultsToArray() API. For mode 1 I haven't found a way to specify an interrupt callback when all acquisistions of the channel list is done (independently from ADC instance) because I noted that it is possible to specify a "List last conversion notification" into "Bctu ADC Notifications" (NXP Configuration tool - MEX file) but I'll have an interrupt for each ADC (2 in my case), instead I'd like to have a single interrupt for all conversions of the list finished: for this reason I'm thinking to use FIFO and watermark. 

For internal policy, I can't share my entire project at the moment.
Channels added into screenshots are both on ADC1 just for testing, but then I'll have to add other channels from ADC0.

Thanks

0 Kudos
Reply
1 Reply

921 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @Drifter22,

I think both modes are fairly common applications, and I see no issue with applying them to your routine. 

For Mode 1, I recommend configuring FIFO + Watermark, as this would enable you to raise an interrupt for a completed "set" of ADC channels. Just keep in mind that notifications are done in a N + 1 logic, meaning that if you have watermark set to 3, notification is called when there are 4 entries in the FIFO and you can do 4 readings of FIFO.

For Mode 2, I think you have two choices. Either SW-triggered BCTU as you've mentioned or continuous ADC scanning (if you do not need various ADC instances). You can use either Adc_Sar_Ip_GetConvData or Adc_Sar_Ip_GetConvResultsToArray to extract the channel result,

There are various BCTU + ADC examples in our community, which may prove useful:

Best regards,
Julián

%3CLINGO-SUB%20id%3D%22lingo-sub-2317779%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ES32K312%20BCTU%20FIFO%2Floop%20switch%20(non%20AUTOSAR%20prj)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2317779%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3EI've%20read%20so%20many%20posts%20regarding%20BCTU%20topic%20and%20examples%20too%2C%20but%20I'm%20a%20bit%20confused%20about%20best%20configuration%20for%20my%20purpose.%3C%2FP%3E%3CP%3EInto%20my%20project%20I%20have%202%20system%20statuses%3A%3C%2FP%3E%3CP%3E1-%20(DC%20brushed%20motor%20PWM%20active)%20ADC%20acquisitions%20triggered%20by%20Emios_1_12%20PWM%20in%20order%20to%20read%20motor%20current%20and%20other%20channels%20synchronized%20with%20PWM%20frequency%20(and%20duty)%3C%2FP%3E%3CP%3E2-%20(no%20actuation)%20I'd%20like%20to%20acquire%20same%20channels%20from%20ADC%20continously%20without%20interruptions%20and%20then%20I'll%20read%20via%20SW%20only%20the%20channel%20that%20I%20need%20for%20a%20particular%20task.%3C%2FP%3E%3CP%3EMy%20analysis%3A%3C%2FP%3E%3CP%3EMode%201%3A%20BCTU%20HW%20triggered%20and%20list%20with%20all%20needed%20channels%3C%2FP%3E%3CP%3EMode%202%3A%20BCTU%20triggered%20started%20once%20via%20SW%20and%20with%20loop%20mode%20active%2C%20in%20order%20to%20let%20conversions%20run%20continously.%3C%2FP%3E%3CP%3EI%20need%20to%20switch%20between%20these%20two%20modes%20(by%20disabling%20HW%20trigger%20or%20stopping%20loop%20mode)%2C%20so%20I'd%20like%20to%20know%20which%20is%20the%20best%20solution%20and%20maybe%20alternatives.%3C%2FP%3E%3CP%3EMy%20question%20is%20related%20also%20to%20which%20destination%20to%20use%20for%20results%3A%20for%20mode%202%20I'd%20use%20ADC%20registers%20and%20then%20read%20with%26nbsp%3BAdc_Sar_Ip_GetConvResultsToArray()%20API.%20For%20mode%201%20I%20haven't%20found%20a%20way%20to%20specify%20an%20interrupt%20callback%20when%20all%20acquisistions%20of%20the%20channel%20list%20is%20done%20(independently%20from%20ADC%20instance)%20because%20I%20noted%20that%20it%20is%20possible%20to%20specify%20a%20%22List%20last%20conversion%20notification%22%20into%20%22Bctu%20ADC%20Notifications%22%20(NXP%20Configuration%20tool%20-%20MEX%20file)%20but%20I'll%20have%20an%20interrupt%20for%20each%20ADC%20(2%20in%20my%20case)%2C%20instead%20I'd%20like%20to%20have%20a%20single%20interrupt%20for%20all%20conversions%20of%20the%20list%20finished%3A%20for%20this%20reason%20I'm%20thinking%20to%20use%20FIFO%20and%20watermark.%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20internal%20policy%2C%20I%20can't%20share%20my%20entire%20project%20at%20the%20moment.%3CBR%20%2F%3EChannels%20added%20into%20screenshots%20are%20both%20on%20ADC1%20just%20for%20testing%2C%20but%20then%20I'll%20have%20to%20add%20other%20channels%20from%20ADC0.%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2319186%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20S32K312%20BCTU%20FIFO%2Floop%20switch%20(non%20AUTOSAR%20prj)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2319186%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F179750%22%20target%3D%22_blank%22%3E%40Drifter22%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3EI%20think%20both%20modes%20are%20fairly%20common%20applications%2C%20and%20I%20see%20no%20issue%20with%20applying%20them%20to%20your%20routine.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20Mode%201%2C%20I%20recommend%20configuring%26nbsp%3BFIFO%20%2B%20Watermark%2C%20as%20this%20would%20enable%20you%20to%20raise%20an%20interrupt%20for%20a%20completed%20%22set%22%20of%20ADC%20channels.%20Just%20keep%20in%20mind%20that%20notifications%20are%20done%20in%20a%20N%20%2B%201%20logic%2C%20meaning%20that%20i%3CSPAN%3Ef%20you%20have%20watermark%20set%20to%203%2C%20notification%20is%20called%20when%20there%20are%204%20entries%20in%20the%20FIFO%20and%20you%20can%20do%204%20readings%20of%20FIFO.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EFor%20Mode%202%2C%20I%20think%20you%20have%20two%20choices.%20Either%20SW-triggered%20BCTU%20as%20you've%20mentioned%20or%20continuous%20ADC%20scanning%20(if%20you%20do%20not%20need%20various%20ADC%20instances).%20You%20can%20use%20either%26nbsp%3BAdc_Sar_Ip_GetConvData%20or%26nbsp%3BAdc_Sar_Ip_GetConvResultsToArray%20to%20extract%20the%20channel%20result%2C%3C%2FP%3E%0A%3CP%3EThere%20are%20various%20BCTU%20%2B%20ADC%20examples%20in%20our%20community%2C%20which%20may%20prove%20useful%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2FS32M-Knowledge-Base%2FS32M27x-S32K3-eMIOS-BTCU-ADC-DMA-RTD600%2Fta-p%2F2155542%22%20target%3D%22_blank%22%3ES32M27x%2FS32K3%20%E2%80%93%20eMIOS%2FBTCU%2FADC%2FDMA%20%E2%80%93%20%5BRTD600%5D%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2FS32K-Knowledge-Base%2FRTD400-LLD-K344-Center-Aligned-PWM-Trigger-ADC-BCTU%2Fta-p%2F2034211%22%20target%3D%22_blank%22%3E%5BRTD400%20LLD%5DK344%20Center%20Aligned%20PWM%20Trigger%20ADC%20BCTU%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2FS32K-Knowledge-Base%2FS32K3-Motor-control-SW-examples%2Fta-p%2F1804577%22%20target%3D%22_blank%22%3ES32K3%20Motor%20control%20SW%20examples%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2FS32K-Knowledge-Base%2FExample-S32K312-PIT-BTCU-ADC-1-BCTU-ADC-DATA-REG-DMA-DS3-5%2Fta-p%2F1787778%22%20target%3D%22_blank%22%3EExample%20S32K312%20PIT%20BTCU%20ADC-1%20BCTU_ADC_DATA_REG%20DMA%20DS3.5%20RTD300%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EBest%20regards%2C%3CBR%20%2F%3EJuli%C3%A1n%3C%2FP%3E%3C%2FLINGO-BODY%3E