2076341_en-US

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

2076341_en-US

2076341_en-US

Flag terminate compute operation

Hello,

I am using the frdm-mcuxc242 board and I would like to know how I can know if a certain operation has been performed.

For example:  If I have to do the sum between two variables A and B and it gives me result C (A+B=C) how can I know if the operation has been performed and finished before reading the result of the variable C?

Is there a computational operation performed interrupt flag? Or can I know how many clock cycles my operation takes? 

Thank you.

Regards

Re: Flag terminate compute operation

Hi @Transidico.,

Analyzing the code you share, one option that could be happening is that ADC has not finish the conversion when the calculation is being made, what I recommend you is to check the SDK example for ADC, adc16_interrupt and adc16_polling, in this examples it shows two options in order to wait the ADC to finish the conversion. In this way you can assure that the ADC has the value of the current voltage on the pin.

Pablo_Ramos_0-1744306261083.png

Best Regards,
Pablo

Re: Flag terminate compute operation

Good morning pablo,
thank you for your reply and the documentation sent. I found how many clock cycles my instruction takes. I am sampling an input signal from pin A0 of the adc at 1ms and I noticed that if I don't put a delay of about 100uS, as you can see in the attached program, the first calculations I get are not accurate. I don't know if I have to put a delay every time I perform an operation, I don't think so because it would affect the timing. I don't know if the delay I am putting in is correct and there is a better way to put it in. Also, I have seen that it is possible to use MSDK_EnableCpuCycleCounter() and MSDK_GetCpuCycleCount() to read the number of cycles the program is doing, but if I implement them in my code it gives me an error. Could you give me some advice?


Re: Flag terminate compute operation

Hi @Transidico,

You can calculate the clock cycles required for the operation with the assembly instruction.

MCUXpresso has the option to see the assembly instruction required for each line in C

Pablo_Ramos_0-1744136989528.png

The instruction will appear while debugging.

Pablo_Ramos_2-1744137015557.png

On the core documentation you should be able to find the number of cycles spend on each instruction.

Cortex-M0+ Technical Reference Manual r0p1

However, I suggest you double check directly with ARM to ensure performance on each instruction.

Best Regards,

Pablo


标记 (1)
无评分
版本历史
最后更新:
‎11-21-2025 09:36 PM
更新人: