cancel
Showing results for 
Search instead for 
Did you mean: 

How many nanoseconds a NOP consumes at 32MHz stm32L152re?

Posted on October 30, 2017 at 01:05

Thank you in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
Posted on October 30, 2017 at 13:15

Hello,

It takes 1 cpu cycle count. maybe 31,25ns. See 

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0337h/CHDDIGAC.html

 

Also the assembler generates alternative instruction which does nothing, such mov r0, r0

Regards

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

4 REPLIES 4
Posted on October 30, 2017 at 02:10

You can measure instruction cycles with DWT_CYCCNT

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on October 30, 2017 at 11:59

Ah, something like this:

uint32_t cycles = 0;
/* DWT struct is defined inside the core_cm4.h file */
DWT->CTRL |= 1 ; // enable the counter
DWT->CYCCNT = 0; // reset the counter
delayUS(1); // <-- here my Nop()
cycles = DWT->CYCCNT;
cycles--; /* We subtract the cycle used to transfer 
 CYCCNT content to cycles variable */�?�?�?�?�?�?�?�?�?

Carmine Noviello tutorial

https://www.carminenoviello.com/2015/09/04/precisely-measure-microseconds-stm32/

Posted on October 30, 2017 at 13:15

Hello,

It takes 1 cpu cycle count. maybe 31,25ns. See 

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0337h/CHDDIGAC.html

 

Also the assembler generates alternative instruction which does nothing, such mov r0, r0

Regards

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Posted on October 30, 2017 at 14:31

Thank you very much!

I tried to use the TSL2591 Lux sensor with hardware i2c master to no avail. The same hardware i2c master library works excellent with the PCF8583 RTC (normal clock operations, daily alarm and weekdays alarm tested so far) so I know that the library is well implemented (made by Tilen and adapted to my needs).

The TSL2591 Lux sensor works with an Arduino board using Adafruit libraries and works as well using my Nucleo board but I want to program it in C using LL. The Adafruit uses a software i2c library and I thought I may need to use one myself. Also I ordered another Lux sensor, MAX44009, much better but the manufacturer recommends a software implementation of the i2c protocol. So, I have that implementation from MAXIM, which I will adapt to my board, but also this as well

https://github.com/GouMinghao/STM32_Software_I2C_Master

 

If MAX44009 doesn't work with the hardware i2c (that would be my first try), I will need the software i2c. So I will need some good delays  (well, whatever makes a functional software i2c).

__________

The latest TRM revision is here

https://developer.arm.com/docs/100165/latest/preface