2010-03-22

mini68k adding libraries and serial port

I admit I haven't been very focused at my hobbies, but that's life. I've been working here and there: getting the Arduino and the SHT11 working together (see here for library), converting a metal-gear servo to continuous rotation (I followed this how-to), trying to design a photodiode amplifier (I'm following this, this and what is available from this), debugging the SolarLight project and working on the schematics of the mini68k and finally getting some code running on it.
I've been feeling a bit more confident with gcc-m68k and I've been increasing the complexity of the programs. I managed to link in the gcc library (libgcc), I tried out the -msoftfloat option (compile, I didn't check the results of a floating operation yet) and I created my own putc and getc functions using the USART of the MC68901 (MFP) in pooled mode.
I want to change my CRT0.S to include some hardware support functions before main() is run. Initialize the interrupt vectors (pointing to a "interrupt error" routine), printing some console message during initialization and doing some hardware test (RAM, MFP).
I'm still unsure of a few things:

  • An interrupt level 7 is basically a NMI, my system switches from ROM to RAM at the 8th clock, at the 9th clock if a NMI is pending the CPU will jump to an uninitialized vector! I must read the specs again but I think this could be a problem. Or not, if the system is int7 incapable (IPL2/0 or IPL1 permanently to 1) or has a gate enabling interrupts;
  • the MFP interrupt is physically enabled (i.e. connected to the CPU or gated by self for example)? (see point above), how does gcc link to interrupts (newer gcc versions work well ex. AVR-gcc), how do I place the vectors in memory?;
  • I want to build a gdb-stub/rom monitor, will it handle the vector allocation/writing? If so, my operating system (loading from somewhere ROM or disk) will also be in supervisor mode? (and also handle these?);
  • Can/Should I implement some sort of memory protection (writes to first 1K-vectors and last 1K-SupervisorStack of RAM must be made in supervisor mode)?;
  • For the end project of a CP/M 68k what type of media do I use? Going back to floppies would be definitely cool but I'm sure I would need some sort of DMA as I don't think the 68000 is fast enough (and surely not at the current speed of 4MHz). With SD I'd use only a few I/O pins (from the MFP?) but some SD cards are only 3.3V and my system runs at 5V. Or I could use a Compact Flash card, most can work at 5V, and it is easy to get some old CF cards (64/128MB) or even a IBM microdrive I've found once here; I would need to build two 8bit ports (A output to control the drive, B for bidirectional data) and this is breadboard space...
  • I would also like to "upgrade" the logic circuits to one of the M4A5-32/32 I've build an adaptor for and change the DTACK circuit to actually drive the line when releasing the bus (until AS goes high).
Well for now that is a still a lot of work in progress, I doubt Spring and/or Summer will allow me more time but I'm trying to keep you posted.

2010-03-07

Arduino OpenSuse 11.2 (LED as light sensor)

I need to use my Arduino-shield-Breadboard for another project, so my Pachube-feed will be offline... for a while...

Next time around I'll add some more sensor that I have, like the relative humidity sensor.
I took the time to upgrade to the new Arduino-0018, here I encountered some old and some new problems.
First I needed to add my user to the dialout group in order to have access to the serial ports, as reported here (see last post). The other problem was an old problem, with the standard avr-gcc distribution of OpenSuse you can't program an ATMega328. I didn't solved it right now but the how to is here. But for now pachube is off-line (correction: is on-line but data is bogus).

Alex has a problem with his home monitoring system, he wants to monitor the amount of Water he uses by counting the turns of the pointer in the meter. He intends to use photo-reflexive sensor like this one.

Trying to help him, I started with using LEDs as sensors, Photodiodes are expensive and photodiode amplifiers difficult to build due to the very low bias current of the amplifier. My best results were using a IR LED as a sensor, but I'm still not sure if it will work with the set, in particular becase the sensor Alex has is a fototransistor not a photodiode, the principle used could be the same but instead of a reverse bias (anode to ground), the foto transistor must be actively biased (emitter to ground), the parasitic capacitor should still be discharged function of the light.

A good source of information is here, and here, I based my code on the Arduino example but I changed the port programming instructions for direct port access instructions (DDRD, PORTD), it is not "elegant" for several reasons but it is a bit faster and gives better results at high light levels.


The available pre-compiled avr-gcc does not allow you to program the Arduino Diecimillia (ATmega328 is only possible to do assembly, no C or C++). So my update of the Temperature monitor will have to wait...