Optimizing code for SAM4E16E

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello.

I wrote a code for my MCU which has MCK 120Mhz.

 

Problem is about this part of code:

 

its part of display driver code

 

uint8_t DATA[420][238];

uint32_t TRANSFER[256];

 

y=19 (not changed during loop)

x=0;
                while(x<420){
                    PIOC->PIO_ODSR = TRANSFER[DATA[x][y]];
                    asm("nop");
                    asm("nop");
                    x++;
                    }

 

And core of problem is tihs:

 

When this code is compiled with optimizer, data are drived to port at 3MHz rate.

 

But I need to have optimizer OFF and than it isnt so fast. Could anyone help how to make this code faster?

 

Many Thanks

Atmel-ICE
Atmel Studio 7.0

Last Edited: Tue. Mar 15, 2016 - 06:34 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But I need to have optimizer OFF

Why?

 

What code is produced when the optimizer is off?  It's really helpful in such situations to see "what is the optimizer NOT optimizing, that I could optimize manually instead."

 

How about this?  You might need to rearrange DATA so that the proper data is contiguous.

    p = &DATA[0][y];
    pend = p + 420;
    while(p < pend){
          PIOC->PIO_ODSR = TRANSFER[*p++];
          asm("nop");
          asm("nop");
          Sloupek++;
     }

I assume that your original code had an increment of x somewhere inside the loop, or it will take a very long time indeed!

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes of course ... I didnt rewrited it here .. I will repair it ... Sloupek is x

problem is that optimizer mesh up another functions which are very time sensitible....
 

Atmel-ICE
Atmel Studio 7.0

Last Edited: Tue. Mar 15, 2016 - 06:38 PM