![]() |
Forum Index : Microcontroller and PC projects : It works perfectly, but is it a horrific mess ?
![]() ![]() |
|||||
Author | Message | ||||
Turbo46![]() Guru ![]() Joined: 24/12/2017 Location: AustraliaPosts: 1636 |
Hi Tom, Did you ever replace the cable on the real controller that was troubling you ![]() Bill Keep safe. Live long and prosper. |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4248 |
Hi Bill, The controller and its replacement cable are even now sitting on my workbench in the cellar taunting me ![]() I did try that controller on the PicoMite (3.3V) and it did actually work, though a little sluggishly compared with my home-made one. It is 12 months ago now, and my memory isn't wonderful at the best of times, but I think maybe it always worked at 3.3V it was at 5V where it gave me trouble even though it was spec'd for 5V (and not for 3.3V) One of these days I will "fix" it and as promised ship you the duff connector to pulverise in your yard ![]() Best wishes, Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4248 |
Wow, that investigation goes rather "above and beyond", thanks. To be honest I can't see any reason I would need to clock a controller at anything near 2 MHz. Unless I'm missing something 1 KHz should be more than sufficient for reading user input shouldn't it ? You talk about SPI which is one of the million things I still have to understand, currently what I'm doing is: Option Base 0 Option Default None Option Explicit Const LATCH_PIN% = 9 ' GP6 Const CLOCK_PIN% = 10 ' GP7 Const DATA_PIN% = 11 ' GP 8 Const PULSE_DURATION! = 0.012 ' 12 micro-seconds SetPin LATCH_PIN%, Dout SetPin CLOCK_PIN%, Dout SetPin DATA_PIN%, Din Pin(LATCH_PIN%) = 0 Pin(CLOCK_PIN%) = 0 Dim i%, out% Do Pulse LATCH_PIN%, PULSE_DURATION! out% = &h0 For i% = 0 To 7 If Not Pin(DATA_PIN%) Then out% = out% Or 2^i% Pulse CLOCK_PIN%, PULSE_DURATION! Next If out% <> 0 Then If out% And &h01 Then Print "A "; If out% And &h02 Then Print "B "; If out% And &h04 Then Print "Select "; If out% And &h08 Then Print "Start "; If out% And &h10 Then Print "Up "; If out% And &h20 Then Print "Down "; If out% And &h40 Then Print "Left "; If out% And &h80 Then Print "Right "; Else Print ". "; EndIf Loop Is this just bit-banging SPI ? Best wishes, Tom Edited 2021-06-19 09:35 by thwill MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 4836 |
Hi Tom, Yeah, you are doing spi in basic. And you invert the data. That is probably because your switches on the controller switch 4021 inputs to ground. About the real controller: if you run a cd4021 at 5v and connect it to a maximite that runs at 3.3v you do get unreliable communication, the cd4021 requires a logic high level of 70% of Its power rail, 5v. That is 3.5v but the maximite is 3.3v. If it works, be happy, but most likely it will be not working. Run the controller at3.3v like you do now, and all is dandy.... Good luck with your game development. If you decide to use hardware SPI you can use my code as an example, but you are tied into using the pins as Peter provides them. Hardware is simpler av faster... software more flexible and educating....;) Volhout PicomiteVGA PETSCII ROBOTS |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4248 |
OK, that's because it is a copy of the original NES design. That sounds plausible. I'd have to dig though my old TBS threads to remind myself exactly what was going on. I did have help from some of the "old hands" so I wonder if we really let such a fundamental explanation escape us. Thank you, Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4248 |
Now that I cast my mind back (and look at the half-deconstructed breadboard from that project), we were pulling the latch and clock signals up to 5V through 4k7 resistors and the data signal was coming back to a 5V tolerant pin on the CMM1. Best wishes, Tom Edited 2021-06-20 02:24 by thwill MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |