diff --git a/miotatsu/riscy/riscy/riscy057.hmml b/miotatsu/riscy/riscy/riscy057.hmml new file mode 100644 index 0000000..4a601c4 --- /dev/null +++ b/miotatsu/riscy/riscy/riscy057.hmml @@ -0,0 +1,62 @@ +[video member=miotatsu stream_platform=twitch project=riscy title="Getting the PWM Interrupts to Fire" vod_platform=youtube id=CXGPKW3NM_k annotator=Miblo] +[0:07][Plug SiFive's Linux-capable HiFive Unleashed chip[ref + site="Crowd Supply" + page="HiFive Unleashed" + url=https://www.crowdsupply.com/sifive/hifive-unleashed]][:hardware :research] +[5:28][Check out the HiFive Unleashed specs[ref + site="Crowd Supply" + page="HiFive Unleashed" + url=https://www.crowdsupply.com/sifive/hifive-unleashed] with exciting thoughts for it in [~riscy RISCY BUSINESS]][:hardware :research] +[16:04][Plan to port pcalc to RISC-V to work on the HiFive Unleashed][:"platform layer" :speech] +[21:35][Determine to continue our investigation into the trap on mstatus in pwm_speed_test.c and to run it in gdb][:speech] +[25:12][Read section 6.2.4 - Debugging Running Programs[ref + site="SiFive Developers" + page="HiFive1 Getting Started Guide" + url=https://dev.sifive.com/hifive1/hifive1-getting-started-guide/]][:research] +[27:33][Comment out the set_csr(mie, MIP_MTIP) and set_csr(mstatus, MSTATUS_MIE) calls in main()] +[28:06][Make and upload pwm_speed_test] +[29:49][Reset the board, to see that we don't trap][:run] +[29:56][Uncomment the set_csr(mstatus, MSTATUS_MIE) call in main()] +[30:08][Make, upload and reset to find that we unexpectedly fail to trap][:run] +[31:15][Reset the board in safe mode, and find that we still fail to trap][:run] +[32:41][Uncomment the handle_m_time_interrupt() and set_csr(mie. MIP_MTIP) calls in main()] +[33:10][:Run to find that we trap after a short delay] +[33:46][Read carefully through handle_m_time_interrupt()][:research] +[36:29][Copy the busy loop from led_fade.c into uart_init() in init.c, and reduce the wait time in handle_m_time_interrupt() to 2 seconds] +[38:11][:Run the program to find that we trap after waiting 2 seconds] +[38:54][Discover the USE_M_TIME #ifdef in init.c and check out the Makefile of other demos that call handle_m_time_interrupt() to find that they contain the flag -DUSE_M_TIME][:research] +[40:35][Add -DUSE_PLIC and -DUSE_M_TIME to the pwm_speed_test Makefile] +[42:00][:Run the program to find that it now works beautifully] +[42:20][Delete all the timer interrupt code, in favour of the PLIC code] +[46:59][:Run the program to see "Hello, World" but no interrupt or trap] +[48:47][Compare our PLIC code with that in global_interrupts.c, try to change PWM0_REG(PWM_CMP0) to PWM0_REG(PWM_COUNT), and instead uncomment the PLIC_set_priority() call in main()][:peripheral] +[53:15][:Run the program and hit our PWM interrupt!] +[53:44][Determine to go back to :timing][:speech] +[55:40][Read Chapter 15 - E300 Pulse-Width Modulation (PWM) :Peripheral[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 :timing] +[56:42][Try setting PWM0_REG(PWM_CMP0) = 0xFFFF][:peripheral :timing] +[57:30][:Run the program to see that our interrupts fire pretty fast][:peripheral :timing] +[57:51][Try to add 0x1 to the timer rearming call][:peripheral :timing] +[58:11][:Run the program to see that our interrupts still fire pretty fast][:peripheral :timing] +[58:26][Bump straight up to 0x7 in the timer rearming call][:peripheral :timing] +[58:44][:Run the program to see that our interrupts still fire pretty fast][:peripheral :timing] +[1:00:42][Note that we wanted to be in one-shot mode, and try making pwm_0_handler() clear the PWM_CFG register][:peripheral :timing] +[1:02:05][:Run the program to see that we are correctly in one-shot mode][:peripheral :timing] +[1:02:44][Rearm the timer in pwm_0_handler()][:peripheral :timing] +[1:03:53][:Run the program to see that the timer gets rearmed each time, and note that it still runs pretty fast][:peripheral :timing] +[1:05:02][Consider the main use-case of PWM interrupts being for debouncing, and plug the Guide to Debouncing[ref + site="The Ganssle Group" + page="A Guide to Debouncing, or, How to Debounce a Contact in Two Easy Pages" + url=http://www.ganssle.com/debouncing.htm]][:peripheral :research :timing] +[1:11:04][Consider alternate ways to handle debouncing, and uses for PWM interrupts][:peripheral :speech :timing] +[1:14:24][Determine that we have a good understanding of global_interrupts, and to start fully learning :timing in the next episode][:speech] +[1:15:44][Plug the new Gumroad-powered subscription solution[ref + site=Gumroad + page="RISCY BUSINESS" + url=https://gumroad.com/riscy], along with a note that the Transparency Reports alone remain solely available publicly on Patreon[ref + site=Patreon + page="miotatsu is creating RISCY BUSINESS" + url=https://www.patreon.com/miotatsu]][:speech] +[/video]