MC9S12C64 ADC question

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

MC9S12C64 ADC question

ソリューションへジャンプ
1,722件の閲覧回数
roberthiebert
Senior Contributor I

MC9S12C64, CW V5.9.0, absolute assembler.

In my program I want to read 5 channels in 8 bit resolution at different points in my program. When I test it on a test program I set an output when the conversion starts, and clear it when the conversion is finished for each channel in succession. Then I record this on my digital signal analyzer to see how long each channel conversion takes. The conversion on Ch0 takes 7.41uS, which is about what I expected. However, each of the next channels take  6uS longer than the previous one.

Ch0 - 7.41uS, Ch1 - 13.42uS, Ch2 - 19.41uS, Ch3 - 25.45uS, ch4 - 31.41uS, Ch5 - 37.41uS.

I'm assuming I have done something wrong in my ADC set up but I can't seem to find it. Any suggestions would be appreciated.

Regards,

Robert 

 

0 件の賞賛
返信
1 解決策
1,554件の閲覧回数
danielmartynek
NXP TechSupport
NXP TechSupport

Hi Robert,

We don't have any interrupt execution time specification, but you may refer to the reference manual of the core.

https://www.nxp.com/webapp/Download?colCode=S12CPUV2

7.5.3 Interrupt Recognition

Figure 7-1. Exception Processing Flow Diagram

I would recommend that you measure it in your setup.

If you use the interrupts, the core will not be blocked in a loop polling the flags, this is the advantage of it.

It also depends on other interrupt and their priorities.

 

Regards,

Daniel

 

元の投稿で解決策を見る

0 件の賞賛
返信
7 返答(返信)
1,555件の閲覧回数
danielmartynek
NXP TechSupport
NXP TechSupport

Hi Robert,

We don't have any interrupt execution time specification, but you may refer to the reference manual of the core.

https://www.nxp.com/webapp/Download?colCode=S12CPUV2

7.5.3 Interrupt Recognition

Figure 7-1. Exception Processing Flow Diagram

I would recommend that you measure it in your setup.

If you use the interrupts, the core will not be blocked in a loop polling the flags, this is the advantage of it.

It also depends on other interrupt and their priorities.

 

Regards,

Daniel

 

0 件の賞賛
返信
1,661件の閲覧回数
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @roberthiebert,

I just briefly checked the code, it seems you selected 8 conversions in a sequence.

movb #$00,ATDCTL3 ; %00010000, 1 conversion

ATDCTL3 = 0x00

 

0 件の賞賛
返信
1,656件の閲覧回数
roberthiebert
Senior Contributor I

Hi Daniel,

Thanks so much for your response. Indeed, that was a typo error on my part. I changed to ATDCTL3 = 0x10. Now the program hangs at line 275.

brclr ATDSTAT1,#%00000100*. The conversion complete flag for channel 2 doesn't seem to be setting for some reason.

Regards,

Robert

 

0 件の賞賛
返信
1,651件の閲覧回数
danielmartynek
NXP TechSupport
NXP TechSupport

Hi Robert,

It should be 0x08 for 1 conversion though.

danielmartynek_0-1730362820155.pngdanielmartynek_1-1730362842223.png

 

0 件の賞賛
返信
1,645件の閲覧回数
roberthiebert
Senior Contributor I

Hi Daniel,

Oh my, another stupid error on my part. I changed ATDCTL3 to 0x08 but now my program just does the conversion for channel 0 then stalls at line 268, waiting for the conversion complete flag. There must be something else involved as well.

Regards,

Robert

0 件の賞賛
返信
1,618件の閲覧回数
roberthiebert
Senior Contributor I

I've made some progress, but I still have a problem. With my revised code, (attached) All the ADC channels will work, but the processing time per channel is ~37 uS, which is unacceptable. If I change ATDCTL3 to 0x08, only channel 0 will convert at ~7 uS, but I get nothing on the other channels. I've tried about all the different combinations of settings I can think of to solve this but so far no joy. Any suggestions would be appreciated.

Regards,

Robert

0 件の賞賛
返信
1,598件の閲覧回数
roberthiebert
Senior Contributor I

OK. I finally figured out where I was going wrong, (revised code attached), but now I have a question.

Depending on how many conversions I want, the processing time varies like this:

2 conversions ~7.42uS, 4 conversions ~8.41uS, 8 conversions ~10.41uS, 16 conversions ~14.41uS.

I am assuming that the more conversions I do, the better the accuracy, but I have to balance this with speed of conversion.

I am sampling the channels at specific times in the main loop. Every time I sample a channel I have to wait for the conversion to complete. Instead of waiting, I could enable the conversion complete interrupt and read the register and save it to the appropriate variable within the interrupt. So my question is, how much time would it take to service the interrupt and which method would be most efficient, waiting for the conversion completion or servicing conversion complete interrupt?

Regards,

Robert

0 件の賞賛
返信