2024-11-11 06:30 AM - edited 2024-11-12 10:00 PM
2024-11-11 06:41 AM
Why do you have three separate timers?
Surely you just need one timer to give you a "tick", and then you do all your sampling and updating on each tick?
@XooM wrote:I have 8 outputs. I read (sic?) them ...
You mean write them?
2024-11-11 06:42 AM - edited 2024-11-11 06:45 AM
Hello,
I suggest you to test your code in a real HW not in simulation with like Proteus/Labcenter.
If needed contact them: https://www.labcenter.com/
2024-11-11 06:48 AM
As you are not using a real HW, the thread has been moved to Other/Software board.
2024-11-11 06:53 AM - edited 2024-11-11 06:54 AM
I don't know. I think I'm doing something wrong.
I use 1 timer to scan 24 LEDs with 2 74hc595.
* When some inputs come, I activate the relevant output.
For example, if (input 1 + input 2 + input 5) comes, I activate the Q1 output.
2024-11-11 06:53 AM - edited 2024-11-11 06:53 AM
I'm working on a real circuit.
2024-11-11 07:03 AM
I don't quite understand.
> I have 8 outputs. I read them with timer17 at 1ms intervals.
Do you want to read back the output values ?
The schematics is too small to decipher any IC types, This outputs seem to be connected said 8-bit shift register. But as said, I can see if as inputs or outputs.
> I have 14 inputs. I read the inputs with timer2 at 1ms intervals to see if there are any inputs.
> I have 8 outputs. I read them with timer17 at 1ms intervals.
Why not read all at once, in the same routine ?
I would use a SysTick interrupt for that, configured to 1ms.
And if you need to care about timing and consistency, add latches to the input.
Otherwise inputs might change in the middle of the read-out process.
> I need a 500ms time delay in such a system, but unfortunately I cannot create this delay and my whole system is blocked. When I set and use a 500ms time interrupt with timer15, the system is blocked.
Sounds like you want to wait inside a (500ms) timer interrupt handler routine for that timeout.
This is a bad idea, as it blocks other interrupts.
This can be done by counter values (variables) from within the SysTick interrupt as well.
Define a global (volatile) variable, and decrement it by 1 in the SysTick handler when not zero.
When the variable is back to zero, the timeout has expired.
2024-11-11 07:12 AM
What STM32 are you using? What board are you using? ST? Custom board?
2024-11-11 07:15 AM - edited 2024-11-11 07:16 AM
@XooM wrote:For example, if (input 1 + input 2 + input 5) comes, I activate the Q1 output.
You didn't mention anything about performing logic on the inputs before driving the outputs.
I suggest that you forget about that to start with, and just get the delay working.
I would suggest using a 500-entry circular buffer. Each millisecond:
For testing, use a much shorter ring buffer - then you can easily see the data "walking" through it...
2024-11-11 07:20 AM - edited 2024-11-11 07:24 AM
I control a total of 24 LEDs on 8 outputs, 3 of which are connected to 1 74hc4094 output.
I am trying to turn on the LED I want by scanning them with a timer.