ADC continuous conversion

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

ADC continuous conversion

2,376 Views
hajianik
Senior Contributor I

Hi,

My target is s32k148.

There are 5 ADC channel that I need to read. One of which I'd like to read on a continuous mode.

I know how to convert all the 5, back to back using PDB,HOWEVER I NEED TO SAMPLE ONE OF THESE CHANNEL ON A CONTINUOUS BASIS.

 the bit ADC_CO in ADC_SC3 will effect all the channels I believe.

Thanks,

Koorosh Hajiani

 

 

 

Tags (1)
0 Kudos
17 Replies

2,356 Views
hajianik
Senior Contributor I

Hi Daniel,

Thanks for your response.

I don't understand what you wrote, it is me and not you, could you expand on it.

Or use one ADC instance for the continuous conversion on a single channel and the other ADC with PDB.

Thanks,

Koorosh

0 Kudos

2,337 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi Koorosh,

The MCU has 2 ADC modules.

So, you can use one ADC to sample the one channel continuously (ADC_CO).

And the second ADC to sample the rest of the channels using PDB.

 

BR, Daniel

 

0 Kudos

2,325 Views
hajianik
Senior Contributor I

Hi Daniel,

OK, GOT IT THANKS, UNFORTUNETLY THE HARDWARE ENGINNER WITHOUT CONSULTING ANYONE HAS SELECTED SOME ON ADC0 AND SOME ON ADC1.

I GUESS THE BEST SOLUTION IS TO USE CONTINUOUS (PDB) ON ALL OF THEM.

IN THAT CASE LET ME ASK YOU THIS :

In sleep mode the ADC is disabled HOWEVER WHEN WE WAKE UP DO WE NEED TO REINITILIZE THE ADC and PDB.

I can't download the example "project Back to back  adc conversion" seems to be an issue with it.

 

Thanks,

Koorosh

0 Kudos

2,310 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hello Koorosh,

There are these stop modes: STOP1, STOP2 and VLPS.

The ADC is fully-functional in STOP2.

danielmartynek_0-1642073287024.png

For the other modes, there is no need to reinitialize the modules, just re-enable the PDB triggers.

 

What example do you mean? 

Can you post a link?

 

Thank you,

BR, Daniel

 

 

0 Kudos

2,288 Views
hajianik
Senior Contributor I

Hi Daniel,

What I did:

set the PDB1 SC continuous bit to 1.then start  conversion  on the adc1 which is linked to PDB1 CHANNEL 0. however this does not work. is there anything else I need to do ?

 

Thanks,

Koorosh 

0 Kudos

2,221 Views
danielmartynek
NXP TechSupport
NXP TechSupport
0 Kudos

2,211 Views
hajianik
Senior Contributor I

Hi Daniel,

THANKS FOR YOUR REPLY, AND FIXING THE LINK.

I DO NEED TO ASK YOU  THIS MORANIC QUESTION:

 

Lets say I configure the ADC for the PDB BACK2BACK single shot , and start conversion however a bit later on, I set the continuous bit in PDB SC register. will that result in continuous conversion?

Also in your post you mentioned that I need to read the result register  for PDB triggering on COCO bit .

does it apply to continuous  conversion too?

 

Thanks,

Koorosh Hajiani

 

0 Kudos

2,163 Views
hajianik
Senior Contributor I

Hi Daniel,

appreciate your help on this and answering my morainic questions.

The S32K RM is not very clear.

So ,Once we read any result register and read it again before the next conversion is done will it read the the last result or its content would be zero or 0xffff or something else?

and what about the COCO bit ? with continuous PDB do I need to read the COCO bit to trigger a new conversion? or this is done by the hardware?

BR,

Koorosh

0 Kudos

2,146 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi Koorosh,

The result register holds the previos valid value until it is overwritten by a new conversion result.

Yes, the COCO flag needs to be cleared by reading the result register.

 

BR, Daniel

0 Kudos

2,139 Views
hajianik
Senior Contributor I

Hi Daniel,

As always thanks for your reply.

Here is the issue. I'm dealing with Autosar code and trying to hack it , not with malicious intention of course. so there is 7 ADC1 channels on PDB1, and you can see below the register content. I'm interested in channel 3 (SC1D )to be read on a continuous basis. so I let the AUtosar do its initialization( single shot) and right after that I set the continuous bit to 1. Although I read RD every 1 ms or even 20 ms I don't see the COCO bit  gets updated. when remove the continuous bit setting, it updates for COCO bit.

hajianik_0-1642791983404.png

BR,

Koorosh

 

0 Kudos

2,099 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi Koorosh,

I don't use Autosar, please create a new thread for this.

I would use the ADC interrupt or the PDB interrupt to check the COCO and to read the result instead of the polling method that you use though.

 

Regards,

Daniel

0 Kudos

2,188 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi Koorosh,

Yes, it can be set later, I don't see any issue with that.

Yes, it applies to the continuous mode too.

 

BR, Daniel

 

0 Kudos

2,300 Views
hajianik
Senior Contributor I

Hi Daniel,

this is the link:

Original Attachment has been moved to: Example-S32K144-PDB-ADC-back2back-v1_0-S32DS12.zip

Thanks

0 Kudos

2,263 Views
hajianik
Senior Contributor I
0 Kudos

2,228 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Thanks Koorosh,

The link has been fixed,

 

BR, Daniel

0 Kudos

2,272 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @hajianik,

Please provide link to the thread where you read:

Original Attachment has been moved to: Example-S32K144-PDB-ADC-back2back-v1_0-S32DS12.zip

I can't locate it,

 

BR, Daniel

0 Kudos

2,362 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hello Koorosh,

I'm afraid it can be done on one ADC instance.

The ADC samples one channel continuously if ADCO = 1, then, it can't convert other channels triggered from PDB.

You can sample all 5 channels continuously from PDB in the back-to-back mode.

Or use one ADC instance for the continuous conversion on a single channel and the other ADC with PDB.

 

Regards,

Daniel

 

 

0 Kudos