LPC55s69 ADC cannot read with watermark > 0

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

LPC55s69 ADC cannot read with watermark > 0

913件の閲覧回数
waliwalabo
Contributor I

Hi, 

I'm trying to use ADC receive 10 data a time and doing average. 

 

This is almost the same from the adc example, in which the adc acquire 3 samples and do averaging.

 

The main difference is I used config tool -> peripherals to setup my ADC and DMA, here is the parameters: 

ADC:

waliwalabo_0-1747436098967.png

waliwalabo_1-1747436113996.png

DMA:

waliwalabo_2-1747436142197.png

 

And I copy the code from the example "lpcxpresso55s69_lpadc_dma":

g_DmaTransferDoneFlag = false;

 

LPADC_DoSoftwareTrigger(ADC0, 1UL);

while ((LPADC_GetStatusFlags(ADC0) & RESULT_FIFO_READY_FLAG) == 0UL)

{

PRINTF("1\r\n");

}

PRINTF("2\r\n");

DMA_StartTransfer(&DMA0_CH0_Handle);

while (false == g_DmaTransferDoneFlag)

{

PRINTF("3\r\n");

}

uint16_t adc_val = (uint16_t)(g_avgADCValue & ADC_RESFIFO_D_MASK);

 

 

if (adc_index < sizeof(adc_data_buffer)/sizeof(adc_data_buffer[0])) {

adc_data_buffer[adc_index++] = adc_val;

}

 

 

The issue I have is that the code is stuck at

while (false == g_DmaTransferDoneFlag)

{

PRINTF("3\r\n");

}

 

unless the "FIFO0 WATERMARK" in the peripheral was changed to 0.

I tried to compare the auto generated pheripherals.c with the ADC_Configuration(void) in the example but no luck.

 

Did I miss some codes, or mass up with some setup?

ラベル(2)
0 件の賞賛
返信
3 返答(返信)

883件の閲覧回数
Harry_Zhang
NXP Employee
NXP Employee

Hi @waliwalabo 

The issue I have is that the code is stuck at

while (false == g_DmaTransferDoneFlag)

{

PRINTF("3\r\n");

}

This proves that DMA is not worked.

This may be due to ADC not being configured correctly or DMA not being configured correctly.

I think you can check the adc dma registers between sdk demo and your code in debug moed.

Harry_Zhang_0-1747624178624.png

BR

Harry

 

 

0 件の賞賛
返信

866件の閲覧回数
waliwalabo
Contributor I

Hi Harry,

 

Thanks for your suggestion.

 

I compared the DAM and ADC. I thought my DAM was almost identical to the example and found something interesting in ADC's register:

waliwalabo_0-1747690587343.png

I took the screen shot when my firmware stuck at the while loop, and FCTRL[0] = 0x00090007.

According to the manual, bit 0:4 is FCOUNT. I tried different watermark like 6 or 8 and when it got stuck, FCOUNT is always smaller than watermark by 2. 

Then I changed the watermark to 2 and my code finially work. 

 

So it seems that if the watermark is larger than 3, the FIFO will never receive enough data, no matter what setup I used in config tool. 

 

I change the watermark and SAMPLE_COUNT in the example and it stops working as well. 

 

Did I miss something in the ADC configuration? I don't think this fifo cannot hold more than 3 words. I found FIFOSIZE in the UM and compared with the register, I can confirm that the fifo size of the example and my code is 4. Maybe this is the reason of all the issues but I didn't find the place to change it in the config tool. 

waliwalabo_2-1747691124774.png

What do you think? 

 

0 件の賞賛
返信

828件の閲覧回数
Harry_Zhang
NXP Employee
NXP Employee

Hi @waliwalabo 

"I change the watermark and SAMPLE_COUNT in the example and it stops working as well. "

I will try to reproduce this issue in SDK demo.

BR

Harry

 

0 件の賞賛
返信