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.

a problem about edma when compiler optimize is used



If compiler optimize is closed,  EDMA is right.

I open compiler optimize. The level is o1, EDMA is right.

When the level is o3, EDMA is wrong. The program halts at judging if EDMA is over. Then I set the optimize level of the  file which realizes the function of my_sing_edma1()  is o1, the problem also exists. IPR is set in register window, so the program shouldn't halt. If I add a printf in front of judging if edma is over, the program is right. Why does this occur? How to slove this problem?

 

  • wu wu said:
    while(!(*unsigned int *)0x01C01068 & 0x00000002));

    The optimizer needs to know that this is not just a simple read of a memory location, but that this is a volatile, changing location that can be different when read multiple times. The optimizer assumes that a pointer to an unsigned integer is nothing more than that.

    while(!(*volatile unsigned int *)0x01C01068 & 0x00000002));

    The volatile keyword is discussed in the Optimizing Compiler User's Guide. Changing it like this should solve this problem.

    This is one of the many problems that you can have when you use hard-coded addresses for directly accessing memory-mapped registers. We have solved problems like this already in the CSL and LLD functions. Please consider either using those functions or at least starting from those functions.

  • According to your method, I add keyword volatile. Now the program runs with no halt. But I find another problem.

    If IPR is set, we should clear it. So after while(!(*volatile unsigned int *)0x01C01068 & 0x00000002)), there is *(unsigned int *)0x01C01070 |= 0x00000002.  I need to use EDMA for many times. But just several times IPR can be cleared at first. After that, IPR cann't be cleared. It seems that *(unsigned int *)0x01C01070 |= 0x00000002 doesn't work. Then I also add keyword volatile, but reasult is the same. If I add a breakpoint in front of the row: *(unsigned int *)0x01C01070 |= 0x00000002, IPR can be cleared.

    At first times when IPR can be cleared, I see IPR's value from register window and by printf it. By both the two methods, the IPR's value is 0.

    At times when IPR cann't be cleared, I see IPR's value also from register window and printf it. When I see from register window, I find the value is 2, while I see by printf it, the value is 0. Why using different ways, the value is different? Which is true value?

  • This is another of the many problems that you can have when you use hard-coded addresses for directly accessing memory-mapped registers. We have solved problems like this already in the CSL and LLD functions.

    Please use the CSL or LLD rather than trying to debug direct register writes.

    You may also find assistance from the TI Wiki Pages. Search for "EDMA3 Programming" and look through the topics that have been written to help you program EDMA3 transfers.