cancel
Showing results for 
Search instead for 
Did you mean: 

Querry regardung clock cycle in stm32f407

sanjib
Associate III
Posted on April 23, 2014 at 14:08

Hi

I am doing a simple thing in C basically witing it to the PORT I register

short int a[1]  = {1,0};

short int *p = &a;

while(1)

  {

         GPIOI->ODR |= *p;

  }

Basically fetching data from memory and writing it to the PORT I . I have to write a very long array but for easier understanding, I have used  small array.  I thought it should take a less clock cycle like 4 max 5 but it is taking so much how can i reduce the clock cycles ...for just writing also it is taking so much clock cycles . what should i do to lessen it

The disassembly for his instruction is

 

 74                   GPIOI->ODR |= *p;

0800042c:   mov.w r3, #8192 ; 0x2000

08000430:   movt r3, #16386 ; 0x4002

08000434:   mov.w r2, #8192 ; 0x2000

08000438:   movt r2, #16386 ; 0x4002

0800043c:   ldr r1, [r2, #20]

0800043e:   movw r2, #56    ; 0x38

08000442:   movt r2, #8192  ; 0x2000

08000446:   ldr r2, [r2, #0]

08000448:   ldrh r2, [r2, #0]

0800044a:   sxth r2, r2

0800044c:   orrs r2, r1

0800044e:   str r2, [r3, #20]

 82         }
4 REPLIES 4
Posted on April 23, 2014 at 14:33

1. switch on optimization in your compiler

2. use DMA

3. use assembler

Are you sure you want to OR the data with the port?

JW

sanjib
Associate III
Posted on April 23, 2014 at 16:11

Yes I didn't get can you show me any examples

Posted on April 23, 2014 at 16:17

Yes, definitely don't want to be using OR, or any RMW instruction, if you want to drive specific bit patterns instead of the entire port bank then consider using the BSRR.

I think there have been other threads, with examples, where this kind of thing has been done with assembler and DMA.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
sanjib
Associate III
Posted on April 25, 2014 at 08:38

Thanks Clive it works ........