From: Hársfalvi Levente (hlpublic_at_freestart.hu)
Date: 2007-04-10 23:59:39
Daniel O'Shea wrote: > Köszönöm! Szívesen! :-) Nincs mit... :-) > Yes, I'm starting to think that a microcontroller might be the best > solution after all... what I'm trying to come up with is a multi-purpose > 9-pin controller that I can use to interface with an XScale PXA270 > processor, but also maintain C64 compatibility as an alternate function. > What's complicating things is that the C64 joystick port has all its > switches on the GND (0V) line, but the PXA270 direct-keypad interface > wants its switches on a 3.3V line... Which at first doesn't seem like > such a problem, until you want to start adding in variable voltage > sources that want a connection to ground and power, if the ground and > power lines are moving around! So now what I'm thinking is if I input > seven switches and two variable voltages to a microcontroller, and then > have seven outputs from the microcontroller, with a jumper or toggle > switch connected to select between 0V and 3.3V mode, so then in 3.3V > mode the seven outputs would be: > > Up, Down, Left, Right, 3 buttons @ 3.3V (and X/Y variable voltage > sources which can bypass the microcontroller and be separately fed > directly to the PXA270, as it has its own ADC) > > ...and in 0V mode, the seven outputs would be: > > Up, Down, Left, Right, 1 button @ 0V and X/Y PWM outputs (here the > variable voltage sources are translated through the microcontroller's > ADC into PWM outputs for the C64) > > After a quick search I'm thinking a PIC16F87xA variant as it has 10-bit > ADC inputs, and two 10-bit PWM outputs - does this seem achievable? (is > the microcontroller's TTL I/O 3.3V?) thanks! Interesting project... ;-) Jim has answered the question above, and I do agree with him (...though, I'd emphasize other arguments). -- On the PIC, one instruction cycle is 4 clock cycles. A 4 Mhz PIC is effectively an 1Mhz MCU (see http://ww1.microchip.com/downloads/en/DeviceDoc/39582b.pdf, page 159 ... I wonder why they don't put more emphasizing on this fact ;-))) ). An Atmel AVR, clocked at 4Mhz is a 4Mhz MCU. -- The above applies to everything "else". The timers in a 4Mhz PIC run at 1Mhz, the external interrupts are catched at 1Mhz time resolution, etc.... none of this applies to the Atmel. (This is especially important, as the key to avoid jitter in an application like yours is high time resolution...). -- Whilst the PIC processor core is effectively a "single workregister <--> register file" -type of core, the Atmel would appear to be a "32 workregisters <--> data memory" type one. With the PIC core's inherent limitations, Microchip had to organize the data ram (register file) into banks... unlike that, the data memory of the Atmel is just plain linear. I personally do (...did) like the PIC's simplicity (way back, when the small cpu core and the few ten bytes of available ram in the mcu just matched each other), but in this league that we're talking about, the Atmel is way more efficient to use. -- Programming up a PIC is a little bit hmmm... hazy business... :-D Microchip has changed the programming algorithm quite often. The Atmels have a pretty well defined SPI (in-system) programming interface and algorithm (it has more, but SPI is the simplest). You can put together a simple programmer which can be used for the whole line of AVRs. Most newer AtMega's (Mega8L, Mega168(V) and co.) can do 8Mhz at 3.3V... you might want to take a look at the datasheets (http://www.atmel.com/dyn/products/param_table.asp?family_id=607). You can probably take Jim's sources that he has published... I haven't tried his code, but if he tested it and it could do 3...255 proportionally / without jitter, then it should be well useable. (BTW, as I suspect not even the original Commodore paddles would let the SID's adc go below 3). ...Note that generating a "pwm signal" for the SID adc is just not enough, we want to fool the SID ADC so that it captures the value that we want it to... for that, the process needs to be sync'd to the start of the SID ADC measurement cycle (which needs to be done precisely)... Jim's sources can be of great help for you here. As of deciding which mode of operation should be the current one for the interface (C64 vs. PXA270): instead of jumpers, you can probably measure the supply voltage of the MCU right in the reset routine. All those Atmels have a built-in voltage reference... measuring the supply voltage by an ADC channel is fully possible. In the reset routine, your code could decide if the unit is powered from 3.3 or 5v, and set things up accordingly. Good luck!, Levente Message was sent through the cbm-hackers mailing list
Archive generated by hypermail pre-2.1.8.