How can represent logical gates in software of STM32F429I?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-07-01 2:18 PM
Hi All;
I am working on an STM32F429I timer (PWM-mode1) to obtain two signals then I want to use AND gate inside the program (the input is the two signals come from timer Ch1 &Ch2) and designate one pin to be the final output.
- Labels:
-
STM32F4 Series
-
TIM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-07-01 2:37 PM
HAL_GPIO_WritePin(OUT_PORT, OUT_PIN, ( HAL_GPIO_ReadPin(IN_PORT1, IN_PIN1) && HAL_GPIO_ReadPin(IN_PORT2, IN_PIN2)) ? GPIO_PIN_SET : GPIO_PIN_RESET);
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-07-01 2:42 PM
Where can I put that
inside while(1) (infinite loop)?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-07-01 2:50 PM
There, or some other periodically called function, your call.
Most would just solder a part on the board, or use diodes, to achieve functionality at wire speeds.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-07-01 5:04 PM
I don't believe there is a way to do this in hardware. You can do it in software as clive1 says, but there is going to be a delay between when the signal changes and when your output pin changes.
If a delay is okay and your CPU is busy doing other things, one option is to set the two pins as interrupts and within the interrupt, read the value of the two pins and update the output. The delay for this would be around 30 ticks if done efficiently.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-07-01 5:23 PM
74C08 has propagation delay 15-20 ns, so using SW is not so bad - relatively speaking...
Edge triggered interrupts (both edges) for both inputs and the interrupt routine (assembly) just reads the inputs and writes the output.
Takes somewhat longer than a logic chip, but not that dramatically.
We're still talking about tens of nanoseconds.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-07-01 5:34 PM
Newer STM32 models implementation this particular function in the timer, see e.g. 'L4, Combined and Asymmetric modes in timers.
In the 'F4, you could do tricks with DMA or maybe master-slave connection of timers, or simply a different time run with the same period but phase shifted, to achieve a waveform similar to what you desire, whether some of this is suitable depend on the details of the application.
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-07-01 9:11 PM
When two channels of a timer are in PWM mode 1, then the software equivalent of an AND gate is finding the minimum of the two duty cycle values.
The hardware solution is to configure both pins as open drain outputs with pullups, internal or external, and wire them together.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-07-02 7:06 AM
Thanks for your replays , but Here in this picture, you can find what I want .
So, is that possible to represent NOT and AND gates by Software instead of HW.
Thanks
I will hear from you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-07-02 7:35 AM
Why trying to do an "AND"? just generate 2 waveforms using DMA on channel toggle in circular pattern with table length adjust...
There is no smartio, so integrate the burst of pulses in the generation to each channel.
