Thursday 4 March 2021

Ben Eater : 6502 : Clock and Loop

 We now have our hello world program using Ben's home made clock and all looks good.  The clock has been really helpful in allowing us to step through programs and run them slowly but we should really run more quickly using an oscillator.  In previous tutorials we looked at a number of timing considerations relating to our chipset.  Now (video #8) Ben guides us through clock considerations for our breadboard circuit. 

All circuits have inductance and capacitance from wires and physical geometry of the system, breadboard circuits suffer more than PCBs.  The unwanted effects include spikes and sluggish changes and they increase with frequency. Looking at the 6502 data sheet we need our rising or falling pulse to transition within 5ns.  Ben checks the diy clock and 5ns response is fine.

The 1mhz clock chip is then connected to the circuit.  Again 5ns response is fine so the 6502 should be fine. However the circuit doesn’t work.  The LCD is reacting more slowly than it should. In fact if you add 750 NOP instructions to commands the circuit works!

Our problem (video #9) is that we don’t check the LCD busy flag before sending the next command to it.  Ben guides through branching, looping and reading LCD values so that we can check LCD status and send commands in an orderly fashion. Our LCD happily displays text with the 6502 working at 1MHz.

Now we have the ability to loop we can tidy up our assembly program to send a message, we store the message characters as data in a block of memory and loop to read through upto a null byte.

Our Hello World is now fully working and we have learnt a huge amount about building basic 6502 systems along the way.





  


No comments:

Post a Comment