2021-01-02 06:16 AM
I am using the STM32L476G Discovery board and I understand that the COMP is able to trigger interrupts using the exti line 21 and that can be used to along with the timer to measure the time between consecutive rising edges or falling edges. However what I'm struggling with is with the coding. I've looked at countless tutorials but I don't quite see a pattern that I can use to implement my own code. Are there perhaps any other resources I can use to help me?
Solved! Go to Solution.
2021-01-03 09:00 AM
Ok thanks for clarifying.
2021-01-06 06:41 AM
I found the Timer option registers on the reference manual but I don't know how I should set TIM3_OR1 to 0b01. Do I simply use an equal sign or is there a function for this. I don't even where I should do this. As in does this whole process occur within the while loop where it says "User Begin Code 3". How did you manage to become an expert on this software because I've been struggling for weeks now to get even a tiny grasp of what's going on. By this I mean whats the general workflow you undertake because Im honestly at the end of my tether here. Sorry for my ramble lol.
2021-01-06 06:51 AM
The problem is I am not sure how to do anything on this IDE. I dont even know how one can create a variable it all seems quite convoluted. Do you perhaps have a suggestion of resources I could use to help me get better aquainted with the software. Perhaps you can site a few examples of how you got started with the ST products.
2021-01-06 04:02 PM
> how I should set TIM3_OR1 to 0b01
There is no other field in TIM3_OR1, so you can simply assign:
TIM3->OR1 = 0x01;
(gcc knows TIM3->OR1 = 0b01, but that's an extension).
If there would be some other field you wouldn't want to mess with, you would mask:
TIM3->OR1 = (TIM3->OR1 & ~0x03) | 0x01;
There may be dedicated symbols defined for this field in the device header and it may be better to use them instead of the magic constants 0x03 and 0x01, but I am lazy to look it up now.
This is quite rudimentary C programming, so maybe you should work towards improving your C programming skills a bit.
> How did you manage to become an expert on this software
I simply did not, I don't use Cube/CubeMX.
> I've been struggling for weeks now
Well, I am programming microcontrollers for somewhat more than 1000 weeks.
But if you do something for weeks yet see no progress, you should perhaps try in some different way.
> By this I mean whats the general workflow
There's surely a manual out there; not sure how helpful it is; you are supposed to click and use only the "usual" features; anything out of usual is mostly a dead-end or leads to more work than you'd expect.
I know it's not helpful what I wrote, sorry, I may be able to help with details, but can't help in general ways how to program.
JW
2021-01-06 04:50 PM
To actually learn microcontrollers, drop the useless "how to click Cube" tutorials and start from the beginning:
https://www.embeddedrelated.com/showarticle/453.php
P.S. And before that learn C programming on a computer.
2021-01-07 05:03 AM
Thanks Piranha, I will make sure to do that.
2021-01-07 05:04 AM
Thanks Jan for you advice, it is very helpful.