A video below explaining the reset sequence of the 6502. With a possible “bug” in the chip, perhaps. Source code shown in the video is available below.
Affiliate links for the items shown:
Arduino Nano: https://amzn.to/3NxD88A
Board wire (red, black, white, green, blue, yellow): https://amzn.to/34IBeA5
Purple board wire : https://amzn.to/3rX3OGn
Various colour LEDs : https://amzn.to/3KeSbS1
Breadboards : https://amzn.to/3oTBJOo
Source code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
// Basic Clock Driver for WDC65C02 system // For XTroncial 6502 computer, see www.xtronical.com // Constants #define RESET 2 // This pin is connected to 6502 reset pin (pin 40) #define CLOCK 3 // This pin connected to clock in pin of 6502 (Pin 37) #define CLOCK_BUT A0 // The button you press to control the clock of the 6502 #define DEBOUNCE_TIME 20 // Amount of time (millis) to wait for any spurios signals from a push button (the time that we are going to debounce for) #define CLOCK_BUT_UP HIGH // value for ClockButtonStatus if button is raised #define CLOCK_BUT_DOWN LOW // value for ClockButtonStatus if button is pressed bool DebouncingClockButton=false; // are we debouncing the clock push button uint32_t DebounceStartTime; // Start of when button state changed uint8_t PreviousClockButtonStatus; // current state of the clock push button, i.e. up or down void setup() { // By default pins on Arduino are initially set to INPUTS. However we will explicitly set them all here pinMode(RESET,INPUT_PULLUP); pinMode(RESET,OUTPUT); pinMode(CLOCK,OUTPUT); pinMode(CLOCK_BUT,INPUT_PULLUP); Reset6502(); } void loop() { // Very simple code just looking for the change in the manual clock button, note this could have been interupt (on pin change) driven // but for our purposes this is fine. CheckClockButton(); } void CheckClockButton() { // Checks the current status of the clock button, performing any debounce if it changes uint8_t CurrentClockButtonStatus; if(DebouncingClockButton==false) // only check button change if not currently debouncing a change of button state (press or release) { CurrentClockButtonStatus=digitalRead(CLOCK_BUT); if(CurrentClockButtonStatus!=PreviousClockButtonStatus) { // button has changed, set the 6502 clock pin to match, set debounce variables digitalWrite(CLOCK,CurrentClockButtonStatus); DebouncingClockButton=true; DebounceStartTime=millis(); PreviousClockButtonStatus=CurrentClockButtonStatus; } } else { // debouncing clock button, basically we ignore any changes of the push button until a certain time (determined by DEBOUNCE_TIME) has passed // here we just check if the time is up and if so clear the DebouncingClockButton flag so we can check the button again if(millis()>=DebounceStartTime+DEBOUNCE_TIME) DebouncingClockButton=false; } } void Reset6502() { // init a reset on the processor, for the 6502 you must hold the reset low for miniumu of two clock cycles, then bring back high // currently at this point the clock is not running digitalWrite(RESET,LOW); // start the reset process delay(1); // Bring reset line back up to complete the hardware part of the reset process digitalWrite(RESET,HIGH); } |
Enjoying this series very much, very informative. Wish I had this taught to me 35+ years ago. Looking for the section on the debugger.
Sorry for late reply, for a few months now my site is being plagued with spam for unsavoury sites and it takes time to run through the comments these days so I put it off for a while.
The next video after the one coming out in next few days is another in this series. Debugger will make an appearance soon, it’s been built for over a year now!