This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

28069 convert RAM to flash, AdcOffsetSelfCal() function not work correctly

Hi,

I am using 28069 for current control of buck converter. When I run it in RAM, everything is fine and result is good. Now I want to burn the code into flash. I changed the cmd file and do all ramfuncs settings, while keeping all other codes the same as before. But when I debug the code, there is something with AdcOffsetSelfCal(). I tried to debug it step by step, but when running into this function, it exists automatically. I wonder what is wrong since it is exactly the same code as in RAM. I tried to comment out this function, but it turns out that ADC conversion result will be affected. So I need to keep the function and let the code run as in RAM, can anyone give some hints?


  • Sorry, it is 28032 that I am using.
  • Hi Yi zhang,

    My guess is that since the offset calibration function runs at maximum sample rate, the CPU becomes relatively too slow when running from flash. Since the offset calibration function is just an example, maybe try using software triggered or ePWM triggered conversions instead.
  • Hi Devin,

    Thanks for your reply. As you said, this might because of slow CPU when running from flash. But I have copy this section from flash to RAM as shown below, will this still the same? And when you refer to other conversions, do you mean that the offset calibration function is too big and I should write my own, or simply not using calibration except DeviceCal?

  • Hi Yi Zhang,

    For this device you are required to do offset self-calibration, so you shouldn't stick with only what is populated by the device calibration function.

    How you do the offset calibration is up to you; it can be done in a variety of ways. We provide an offset self calibration function as an example, but depending on how your application does sampling you may want to do something a little different. The provided function collects data at the maximum possible sample rate, but this is sensitive to having enough CPU bandwidth (so running out of flash may not work). You could do something simpler, like software trigger a single conversion at a time in a loop. This won't be time critical, so you could probably run it directly from flash.

    I do agree that if you burn the example function into flash, but then copy it to RAM, it should work. Have you tried inserting a breakpoint so that you can check if the PC is at a position in flash or RAM while the function is running?
  • Hi Devin,

    I tried to simplify the offset self calibration example code, which can run in flash. But the problem is that the ADC result is a little different from when example code is used, which is confused. So what I did is using only Device calibration function. Then the code runs well in flash and ADC results can match real voltages and currents now. I checked the reference guide and it doesn't mention that using offset self calibration is a must. As the program is good for now and I wonder if I can forget about self calibration.

    Thanks,

    Yi

  • Hi Yi,

    The requirement to do at least one-time self-calibration for offset comes from the datasheet (see below).  Basically we can't guarantee offset performance without doing self-calibration.

  • Hi Devin,

    Thanks for the clarification and I found it in the datasheet as well. I will keep that in mind although I may not re-add self calibration to my code for now. I have struggled on this issue for nearly one week and do not want to go back again.

    Thanks,
    Yi