This video talks about the code to generate different waveforms on the Flipper Zero. This video is focused on the coding, I highly recommend you watch the concept video first that explains all of the timer concepts we will be using ( • [96] Flipper Zero - Timer concepts ).
If you just want to learn how to make an arbitrary waveform using timers, jump ahead to 8:40 in this video. You can also use bit-banging like shown in 0:38 combined with furi_delay_us for more accurate timing. See the wiki page for additional details and more coding examples.
Join the discord server (conversations and giveaways):
/ discord
Support the channel:
Option 1. Like, Subscribe and click the Bell (to get notified)
Option 2. https://ko-fi.com/codeallnight (donate $3 via PayPal or Venmo)
Option 3. Click the "Thanks" button on YouTube.
Helpful links:
WIKI @ https://github.com/jamisonderek/flipp...
Previous Video - • [96] Flipper Zero - Timer concepts
Lesson summary:
bit-banging is the easiest method. You just transition the pin and then sleep for the desired length of time.
Sleeping has overhead, so be sure to measure if you need accurate pulses.
Toggle just toggles the output of a GPIO pin at some rate.
The internal clock runs at 64MHz (64,000,000 times a second)
Prescaler will make an output pulse every N input pulses. (The prescaler is 0-indexed so 0 means every time, 1 is every other time, 2 is every 3rd time, etc.) If you set to 64000 then you have 1000 pulses per second.
Autoreload triggers the event every N pulses. (The autoreload is 0-indexed. A value of 1000 with a prescaler of 64000 would trigger an event once a second.)
Pulse Width Modulation (PWM) has a duty cycle and is on for some percentage of time, then off for the rest. You can change the polarity if you prefer off for some duration then on for the rest.
For PWM the Compare Value is the duty cycle (the count at which the pulse switches states). For a 50% duty cycle, you would set "Compare Value" to half of the "Autoreload" value.
Direct Memory Access (DMA) event can happen whenever a timer finishes. We can use DMA to change the duty cycle, the duration, or even set/reset a GPIO pin state.
The timers expose various registers that can be set directly using DMA.
Timeline:
0:00 Introduction
0:30 Wiki has code
0:38 Bit-banging (GPIO write)
1:33 Logic Analyzer
1:50 401ms duration (due to instruction delay)
2:02 Bit-banging (Register write)
3:03 delay_us 399,989 for 400ms delay
3:23 TIM1 Toggle
5:21 furi_hal_pwm_start
5:59 TIM1 PWM1
6:56 TIM1 PWM1 DMA (CCR1 - Duty Cycle)
8:40 TIM1 Toggle DMA (ARR - AutoReload) ** MAKE ANY WAVEFORM **
9:47 TIM1 PWM DMA (RCR - Repetition counter, CCMR1 - mode)
11:41 Summary
Смотрите видео [98] Flipper Zero - Writing code for GPIO signals онлайн, длительностью часов минут секунд в хорошем качестве, которое загружено на канал Derek Jamison 06 Январь 2024. Делитесь ссылкой на видео в социальных сетях, чтобы ваши подписчики и друзья так же посмотрели это видео. Данный видеоклип посмотрели 1,543 раз и оно понравилось 35 посетителям.