[video member=miotatsu stream_platform=twitch project=riscy title="Trying to Get Our PWM Interrupts to Fire" vod_platform=youtube id=ng-JAY75j88 annotator=Miblo]
[0:08][Recap and set the stage for the day with a working toolchain][:speech]
[2:26][Make and upload pwm_speed_test to the HiFive1]
[4:08][Connect to and reset the HiFive1, and see "Hello, World!"][:run]
[6:22][Check the Freedom E SDK's current init.c file[ref
    site=GitHub
    page=sifive/freedom-e-sdk/blob/master/bsp/env/freedom-e300-hifive1/init.c
    url=https://github.com/sifive/freedom-e-sdk/blob/master/bsp/env/freedom-e300-hifive1/init.c] and the forums[ref
        site="SiFive Forums"
        page="Does anyone else have problems with output?"
        url=https://forums.sifive.com/t/does-anyone-else-have-problems-with-output/446] for information on busy-looping to let the uart settle]
[10:04][Thoughts on dynamically setting how long to wait, based on the CPU frequency][:speech]
[11:41][Build, upload but unfortunately fail to connect to the HiFive1]
[13:42][Try to debug our program with gdb[ref
    site="SiFive Developers"
    page="HiFive1 Getting Started Guide"
    url=https://dev.sifive.com/hifive1/hifive1-getting-started-guide/]]
[16:16][Try to print "Hello World!" in the infinite loop]
[17:07][Connect to the HiFive1 and see garbage being printed][:run]
[17:50][Add "\\r" to the end of the printf]
[18:14][Connect and see it printing "Hello, World!"][:run]
[18:44][Revert to performing the "wfi" in the loop, and printing "Hello World!" before it, build and upload it]
[19:15][Reset the HiFive1 and see no output][:run]
[20:19][Comment out the "wfi" and ensure that the while scope loops infinitely]
[21:57][Connect to the HiFive1 and see our "Hello, World!"][:run]
[22:27][Decide against using the "wfi" instruction]
[23:23][Connect to the HiFive1, see the power lights flickering, and reconnect the power cable][:run]
[24:53][Try to upload and connect, but still see no output][:run]
[25:40][Try a full rebuild and upload]
[26:02][Connect to the HiFive1 and see a "Hello, World!" but no pwm interrupt][:run]
[27:02][Closely read through the code, and compare it with the led_fade.c demo]
[30:03][Configure the PWM in ENALWAYS mode and with PWM_CMP0 = 0[ref
    site="SiFive Developers"
    page="Freedom E300 Platform Reference Manual"
    url=https://www.sifive.com/documentation/freedom-soc/freedom-e300-platform-reference-manual/]][:programming :research]
[36:48][Connect to the HiFive1, see the "Hello, World!" but still no interrupts][:run]
[37:29][#include platform.h and set the pwmscp0ip bit[ref
    site="SiFive Developers"
    page="Freedom E300 Platform Reference Manual"
    url=https://www.sifive.com/documentation/freedom-soc/freedom-e300-platform-reference-manual/]][:programming :research]
[41:54][Connect to the HiFive1 and see no change][:run]
[42:44][Scour the Freedom E SDK demos for interrupts that use the PWM][:research]
[44:27][See how the global_interrupts demo handles the interrupts][:research]
[49:45][Determine that the only difference between global_interrupts and our pwm_speed_test is that we are not setting the priority or the compare registers][:speech]
[50:45][Try to use exactly the same PWM configuration as global_interrupts]
[53:08][Connect to and reset our HiFive1, but still see no PWM interrupt][:run]
[54:24][Try to set the priority and enable timer interrupts]
[56:57][Reset our HiFive1 and see a "trap"][:run]
[58:29][Note that global_interrupts is setting a handler for the timer interrupt and calling set_timer()][:research]
[59:20][Introduce handle_m_time_interrupt()]
[1:04:41][Connect to our HiFive1 and see one instance of "handling timer interrupt" before a "trap", yet no "Hello, World!"][:run]
[1:06:29][Search the demos for MTIP and consult demo_gpio for their timer handling][:research]
[1:07:27][Make handle_m_time_interrupt() disable and reenable the MTIP]
[1:10:05][Connect to our HiFive1 and see the same output][:run]
[1:10:29][Make handle_m_time_interrupt() print "leaving timer interrupt"]
[1:11:03][Connect to our HiFive1 and see the "leaving timer interrupt"]
[1:11:34][Comment out the set_csr(mie, MIP_MTIP) call in main()]
[1:11:53][Connect to our HiFive1 and see that we are still trapping][:run]
[1:12:09][Comment out the following set_csr() calls]
[1:12:40][Connect to our HiFive1 and see the "Hello, World!"][:run]
[1:13:13][Uncomment the set_csr(mstatus, MSTATUS_MIE) call in main()]
[1:13:35][Connect to our HiFive1 and hit the trap][:run]
[1:14:14][Try various combinations of interrupts, :run the program and always hit the trap][:programming]
[1:16:27][Comment out everything except the set_csr() and printf() calls]
[1:17:10][Connect to our HiFive1 and still trap][:run]
[1:17:54][Make and upload demo_gpio]
[1:18:49][Reset our HiFive1 and see everything working as expected][:run]
[1:19:12][Read the documentation for some gotcha related to mstatus[ref
    site="RISC-V"
    page="Draft Privileged ISA Specification v1.9.1"
    url=https://riscv.org/specifications/privileged-isa/]][:research]
[1:21:13][Wrap it up with the determination to continue our investigation next time][:speech]
[/video]
