Skip to main content

Posts

Showing posts from November, 2024

My journey with ATTiny4313 (part 6)

Part 6: Debugging Bugs are everywehere... Simulating MO44.DRV During my journey, I used my Atari with Cubase and the driver MO44.DRV. However, since my prototype is not yet recognized by the driver, my testing ability is limited. To overcome this issue, I decided to use another ATTiny to simulate the driver. I wrote a quick program (simulmo4) and checked the result with Saleae Logic. Great, exactly what I wanted! Slowing down the simulation My simulator was too fast for an easy debugging. So I decided to slow it down in 2 ways: By setting the CKDIV8 fuse (divide clock by 8) using this link https://www.engbedded.com/fusecalc/ By setting the CLKPR register (clock prescaler) to 00000011 (prescaler division factor = 8, cf. datasheet page 33) .equ PRESCALER, 0x03 ... ; --------------------------------- ; Configuration of system clock prescaler ; --------------------------------- ldi r16, (1<<CLKPCE) STORE CLKPR, r16 ; Permit c...

My journey with ATTiny4313 (part 5)

Part 5: Implementation of a State Machine What is a State Machine? Simply stated, it's an algorithm with a finite number of possible states. The machine transition from one state to another based on the input. In our case, we now what the MO44.DRV driver will send: a reset hardware, followed by the data for each of the 4 outputs. Every time, the /STROBE is pulsed down to warn the MO4 that a new byte is available (cf.   part 4 ). The algorithm S1 If Strobe then State = S2 S2 If Strobe then State = S3 S3 If Strobe then State = S4 S4 If Strobe then State = S5 S5 If Strobe then If unit = 0 then State = S1 unit = 4 else Read counter If counter = 0 then unit = unit - 1 else If unit = ME then State = S62 else State = S61 End End End End S61 If Strobe then While counter > 0 do nothing State = S5 unit = unit - 1 End S62 If Strobe th...