Jump to content

External Interrupt vs Polled input?


yogi
 Share

Recommended Posts

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: BRK 

the BRK then fetches the address from 6 and 7 which points to 0000h. 

0000: LDY #<data byte> 
0002: STY 040<address byte> 
0005: BRK 

and 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

1. Are there user pins that can be used as External Interrupt sources?

2. 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?

3. 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  

Link to comment
Share on other sites

Hi Yogi,

 

using an external interrupt will be the right choice.

I can't give you a ready made example for this yet, but according to the STM32F4 reference manual all 140 GPIOs can be mapped to the EXTI unit (see chapter 10.2.5, External interrupt/event line mapping), so that any free GPIO pin can be used to trigger EXTI interrupts.

 

I'm planning to use this function soon for the DIN Sync inputs of MBSEQ - so sooner or later I can give you more information and even a programming example if required.

 

Best Regards, Thorsten.

Link to comment
Share on other sites

MIOS32_IRQ_Install, the ISR handler together with some EXTI register configurations should be sufficient.

 

I don't see the need for MIOS32_IRQ_DeInstall()

 

Best Regards, Thorsten.

 Oh excellent Just been reading chapter 12 so it's a little clearer. The pin mapping seems much easier then Microchip's PPS / Ext/ INT system. Still trying to work out how the ISR handlers are vectored, are there assigned addresses for the jump vectors? Will have to search a bit for an app note that covers this.

   unattachISR() as used in the project's Arduino code, was to cut down on ISR calls, I think. Ignoring the 2A03 between APU frame updates. It's probably not an issue with the ARM but the 2A03 circuit will generate a interrupt every 6.7 mS ( the max update rate this circuit can handle) regardless if we have new data pending or not. As long as there is minor impact on the system, the regular ISR calls could be used for synchronizing with the CPU/APU.  Could be very useful for direct DPCM playback timing, but still have much research to do there. But with the DAC on the Disco, it's hard to devote much effort to sample playback on the NES CPU, I'll have to think more about that.

  Thank you very much for your help, 

Yogi.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...