Using an SD card with the AVR – DOS File System Print
Written by Vilko Sustič   

If you are designing a device which would, for example, control your house or workshop, protect your home from burglars, water leaks or fire etc., then you need some sort of data logger for later examination of the above-mentioned events. You might want to know who has entered a code on the keypad, when there was a power supply failure, what has caused an alarm to be tripped, etc.

My project involved controlling a central heating system: logging temperatures and controlling an oil burner and pumps. While doing this, I had an unpleasant surprise: the microcontroller would reset itself, on its own, for no apparent reason. Studying the program, I did not find a problem, so I added the capability of logging to an MMC card. I began logging the entry to and the return from all subroutines, as follows:

 Readtemp:
Print #2 ,  Hex(sph) ; Hex(spl) ; “ E: Readtemp”
. . . .
Print #2 ,  Hex(sph) ; Hex(spl) ; “R: Readtemp T=”; temperature
Return

I printed the following: (Hex(sph) ; Hex(spl)) because I also wanted to know what was happening with the stack as well. I suspected that the problem laid there! I used a card similar to the ones used in digital cameras, having a large memory capacity. This made it possible to write to the card for a month or so. To do this, I needed AVR-DOS. Unfortunately, AVR-DOS requires a lot of RAM memory, so it can only be used with microcontrollers like the ATmega32 or other AVR family members with as much or more RAM.

On the left of Figure 1, you can see the IDC connector which connects to the Mini-Pin development board, while on the right you see the MMC card socket. The MMC card requires a 3.3V power supply. However, if our microcontroller operates at 5V, then we need a suitable voltage regulator, such as the GL1117-33. Also, the signals coming from the microcontroller (SS, MOSI, CLK) must be lowered, by means of a resistor network, to comply with the MMC 3.3 V logic levels. The MISO signal, coming from the MMC card, is at a 3.3V logic level, which our microcontroller already accepts as a logic 1. All 4 signals (MISO, MOSI, CLK & SS) are connected to free microcontroller I/O port pins, which we must later assign within AVR-DOS.

Using an SD card with the AVR – DOS File System

2012_AVR_UK_83

Continue reading

Shop area

Last Updated on Wednesday, 01 August 2012 14:39