Hi and Happy Holidays!
I’m trying to determine a way to port a project to MIOS32 or MIOS8 (very cheap for me).
For background, over at Shiftmore Blog is an interesting project :
http://shiftmore.blogspot.com/2012/11/arduino-controlled-nes-2a03-synth-part.html
It is based on the Chip Mastro NES midi interface cart, which in turn is based on a logic design that was presented in a '08 thread @ NESDEV
http://forums.nesdev.com/viewtopic.php?t=3836
Post #12 by kevtris presented a state machine circuit that generates a simple loop on the 2A03 CPU for pushing data to the on chip APU registers.
So, on reset, the CPU fetches data from FFFC and FFFD and will pull the reset vector 0040h (since it’s coming from addresses 4 and 5).
This will get the ball rolling, and the CPU will perform the following three opcodes:
0040: LDY #<data byte>
0042: STY 040<address byte>
0045: BRKthe BRK then fetches the address from 6 and 7 which points to 0000h.
0000: LDY #<data byte>
0002: STY 040<address byte>
0005: BRKand the cycle repeats, over and over again. Your microcontroller or whatever can simply monitor one of the read toggles on one of the latches to figure out when the chip has performed the write.
The Shiftmore version uses a couple of 'HCT595s to interface an Arduino UNO (low pin count) to the 2A03, using SPI rather then 16 port pins. It seems like a do-able project to move this hardware to a MIOS platform, STM Disco. But I’m a little confused as to one aspect; the circuit uses one of the outputs of the 'HCT138 to signal the ‘safe’ window to update the register data to the 2A03. It’s a simple matter to use attachISR() in Arduino but is there a similar function in MIOS32?
SO my questions are
-
Are there user pins that can be used as External Interrupt sources?
-
If so, are there provision with in MIOS32/FreeTOS? I have looked at MIOS32_IRQ_Install() and I think it might be what I need. Can anyone point me to a reference for the CMSIS SVD, for an external Interrupt or a code example?
-
If #1 and 2 are not supported, would it be better to use MIOS32_TIMER() @ ~100uS or less, and poll one or more outputs from the 'HCT138 to determine the current step the state machine is at?
I’m concerned that using polling will miss a pass of the 2A03 loop, we need to catch every loop pass. The whole loop takes ~6.8mS and we have a window of about half that when it is safe. (the 2A03 instruction cycle is 559uS x 12 cycles total).. Though this may not be a problem if the TIMER fires @ <= 100uS.
If I read the top 5 outputs, Y7:Y3 (safe during this window), of the 'HCT138, the worst case wait would be 2.23mS; from the end of the ‘window’ to the next ‘window’. But there is the pin overhead with this. J10B would be OK for this?
The basic code would be something along the lines of this:
Transfer_to_2A03()
RC -> low
shift out 16 bits to the 'HCT595’s serial registers
start TIMER to test for 2A03 state // Or Ext Interrupt
Return
On_TIMER() // Or Ext Interrupt
Read J10B pin(s)
Test state: pin(s) Low = safe
If state is safe, RC -> High // latch serial data to par output latch to be read by 2A03
disable TIMER and return.
Else, return and wait for next TIMER event.
Thank you and any advice would be welcome,
Yogi