cinera_handmade.network/miotatsu/riscy/riscy/riscy032.hmml

66 lines
4.6 KiB
Plaintext

[video member=miotatsu stream_platform=twitch project=riscy title="Understanding Left & Right Aligned Waveforms" vod_platform=youtube id=mAh53LoEzVQ annotator=Miblo]
[0:07][Recap and set the stage for the day]
[0:27][@luismarques83][Hello!]
[0:58][Consult Megan's explanation of the PWM code[ref
site="SiFive Forums"
page="The Big RISCY BUSINESS Question Thread"
url=https://forums.sifive.com/t/the-big-riscy-business-question-thread/531]
in conjunction with the documentation[ref
site="SiFive Developers"
page="Freedom E300 Platform Reference Manual"
url=https://www.sifive.com/documentation/freedom-soc/freedom-e300-platform-reference-manual/]][:peripheral :research]
[4:09][Determine to experiment with the code, with a view to understanding the PWM better][:peripheral]
[4:33][@luismarques83][I had never seen a right-aligned diagram, I think. Weird]
[5:50][@luismarques83][Ah, it's not the diagram, it's the PWM in the device]
[6:02][Try to enable only the green LED to light up][:peripheral]
[7:55][@luismarques83][When you said there were some modes where it was "center aligned", I thought that in the diagram the time flowed from left to right as usual ("left aligned"), and therefore the unexpected transitions had to do with the behavior of the PWM in the device, and not an issue in the documentation diagrams]
[9:28][@luismarques83][I think you are assuming correctly]
[9:36][Try setting G to 0x0 in order to keep the LED at a constant brightness][:peripheral]
[12:42][Upload out program, :run it, and do not see a light][:peripheral]
[13:45][Change G to 0xFF and :run][:peripheral]
[15:13][:Run and now see the green light][:peripheral]
[15:41][Set G back to 0x0 and invert the output][:peripheral]
[16:19][:Run and see a fully bright green light, as a right-aligned waveform[ref
site="SiFive Developers"
page="Freedom E300 Platform Reference Manual"
url=https://www.sifive.com/documentation/freedom-soc/freedom-e300-platform-reference-manual/]][:peripheral]
[17:17][Set G to 0xFFFF, :run it and see that the LED is off, as expected]
[18:00][Experiment with generating a centre-aligned waveform][:peripheral]
[19:46][:Run and see it lit up, with G = 0xFFFF][:peripheral]
[20:05][Note that only the duty cycle matters to us, not the alignment, and describe what the code for Red is doing][:peripheral]
[21:27][Try applying to G the code for red][:peripheral]
[23:56][Read into generating centre-aligned waveforms[ref
site="SiFive Developers"
page="Freedom E300 Platform Reference Manual"
url=https://www.sifive.com/documentation/freedom-soc/freedom-e300-platform-reference-manual/]][:peripheral :research]
[26:54][The :mathematics of centre-aligned waveform generation[ref
site="SiFive Developers"
page="Freedom E300 Platform Reference Manual"
url=https://www.sifive.com/documentation/freedom-soc/freedom-e300-platform-reference-manual/]][:blackboard :peripheral]
[30:25][@luismarques83][You mean 7FFF?]
[30:46][Counting from 0 → 0x7FFF][:blackboard]
[31:56][@luismarques83][It depends on what you mean. If it counts until the MSB but not including it then it would be 0x7FFF]
[32:38][The values count up until the MSB is set, and then back down[ref
site="SiFive Developers"
page="Freedom E300 Platform Reference Manual"
url=https://www.sifive.com/documentation/freedom-soc/freedom-e300-platform-reference-manual/]][:blackboard]
[34:53][@luismarques83][I'll check the source code for the hardware]
[35:24][Read the documentation on PWM Compare Registers[ref
site="SiFive Developers"
page="Freedom E300 Platform Reference Manual"
url=https://www.sifive.com/documentation/freedom-soc/freedom-e300-platform-reference-manual/]][:peripheral :research]
[37:54][How n centre-aligns the waveform][:blackboard]
[40:24][An example centre-aligned waveform when n is within the range 0 to 0x7FFF][:blackboard]
[48:11][Determine to understand why the extra << 1 is required]
[49:30][An example centre-aligned waveform for n >= 0x8000][:blackboard]
[51:47][An example left-aligned waveform for n == 0xFF0][:blackboard]
[56:20][Set G = 0xFF0]
[56:50][@luismarques83][Our perception of brightness is not linear, so that might explain it][:biology]
[57:03][Upload our program and :run it to see that it's not as bright as the full brightness][:peripheral]
[57:36][@luismarques83][I can check the actual PWM with my oscilloscope]
[58:10][@luismarques83][Okay. Is your code online?]
[59:29][An example centre-aligned waveform when n == 0xFF0, which << 1 would presumably make brighter][:blackboard]
[1:02:56][The previous waveform, inverted][:blackboard]
[1:03:47][Review our newfound understanding with a request to @luismarques83 to tweet the findings]
[/video]