64 lines
4.5 KiB
Plaintext
64 lines
4.5 KiB
Plaintext
[video member=miotatsu stream_platform=twitch project=riscy title="Diving Into Pulse Width Modulation" vod_platform=youtube id=wBy4tjKEF3s annotator=Miblo]
|
|
[0:07][Recap and set the stage for the day]
|
|
[2:08][Try commenting out the leds variable initialisation in gpio_demo.c]
|
|
[5:18][:Run our program, see the blinking lights and consider the leds variable to be dead code]
|
|
[6:03][Try commenting out the GPIO_REG(GPIO_INPUT_EN) call]
|
|
[7:45][:Run and see that this makes no difference either]
|
|
[8:11][Try commenting out the GPIO_REG(GPIO_INPUT_EN) call]
|
|
[9:24][:Run and see that the LED does not light up now[ref
|
|
site="SiFive Developers"
|
|
page="Platform Reference Manual"
|
|
url=https://www.sifive.com/documentation/freedom-soc/freedom-e300-platform-reference-manual/]]
|
|
[10:55][Determine to look at setting the LED intensity]
|
|
[13:08][Take a brief look at the GPIO_REG(GPIO_OUTPUT_EN) bit-banging][:research]
|
|
[16:32][:Research LED-related functionality in led_fade.c]
|
|
[20:15][@hossein1387][It is setting the output to be inverted]
|
|
[21:10][Read about HW I/O Functions (IOF)[ref
|
|
site="SiFive Developers"
|
|
page="Platform Reference Manual"
|
|
url=https://www.sifive.com/documentation/freedom-soc/freedom-e300-platform-reference-manual/]][:hardware :research]
|
|
[23:58][@hossein1387][Because in the schematic of GPIO the xor is in the pin data path, in other words, you have the option to invert the pin value by hardware, you can obviously do the same thing in software]
|
|
[25:45][Consult the figure detailing the structure of a single GPIO Pin with Control Registers,[ref
|
|
site="SiFive Developers"
|
|
page="Platform Reference Manual"
|
|
url=https://www.sifive.com/documentation/freedom-soc/freedom-e300-platform-reference-manual/] wondering why you invert the output using a separate register]
|
|
[26:43][@hossein1387][No, it's pretty standard in ARM and other mcus]
|
|
[28:03][Read about HW I/O Functions[ref
|
|
site="SiFive Developers"
|
|
page="SiFive HiFive1 Getting Started Guide"
|
|
url=https://static.dev.sifive.com/dev-kits/hifive1/hifive1-getting-started-v1.0.3.pdf]][:research]
|
|
[29:23][@hossein1387][I think it is because of performance, because bit operation in C needs a couple of instructions to do the same thing while you can just setup a register to do that for you in hardware]
|
|
[31:08][Determine to learn about the PWM]
|
|
[33:05][@hossein1387][IOFs are to set the functionality of the pin. Because you just have a few physical pins on your chip, you can't have a pin to do only GPIO or UART or SPI or PWM. So the IOF selects what functionality you want from that pin]
|
|
[35:11][Read about the Pulse-Width Modulation (PWM) :Peripheral[ref
|
|
site="SiFive Developers"
|
|
page="Platform Reference Manual"
|
|
url=https://www.sifive.com/documentation/freedom-soc/freedom-e300-platform-reference-manual/]][:research]
|
|
[39:04][Wonder if we can send different intensities over a pin]
|
|
[41:32][Continue reading about the PWM[ref
|
|
site="SiFive Developers"
|
|
page="Platform Reference Manual"
|
|
url=https://www.sifive.com/documentation/freedom-soc/freedom-e300-platform-reference-manual/]][:research]
|
|
[42:08][@hossein1387][No, the output is only 0 or 3.3/5 (digital). The PWM is just a pulse wave but you can tell it how long to be on or off. This way the average out put is no longer 0 or 5 but anything in between]
|
|
[43:08][Wave sampling and generation][:blackboard]
|
|
[46:18][@hossein1387][[ref
|
|
site=Wikipedia
|
|
page="Pulse-width modulation"
|
|
url=https://en.wikipedia.org/wiki/Pulse-width_modulation]][:research]
|
|
[47:35][@hossein1387][If you look at the image, the PWM value is only 1 or -1, but the red line is the average]
|
|
[49:20][@hossein1387][One more thing to look is: the width of the pulse, if the pulse is 50% 1 and 50% 0, the average is 0]
|
|
[49:59][:Research pulse-width modulation[ref
|
|
site=Wikipedia
|
|
page="Pulse-width modulation"
|
|
url=https://en.wikipedia.org/wiki/Pulse-width_modulation]]
|
|
[55:52][@hossein1387][Yup, but I don't know the third state you were talking about]
|
|
[56:48][@hossein1387][No, we don't have negative voltage, so it's 0 or 3.3v / 5v]
|
|
[1:01:12][@hossein1387][Okay, so for the pin to detect 1 in binary the pin voltage should be within a threshold, say 3v-3.3v; for binary 0 it should be between 0v-0.5v and the in between voltage is not valid. Meaning any binary value can be assigned]
|
|
[1:02:21][@hossein1387][The voltage threshold is dictated by the CMOS process]
|
|
[1:03:31][Continue to :research pulse-width modulation[ref
|
|
site=Wikipedia
|
|
page="Pulse-width modulation"
|
|
url=https://en.wikipedia.org/wiki/Pulse-width_modulation]]
|
|
[1:10:54][Determine to sleep on this]
|
|
[/video]
|