bps. The escape character is 0x26, which is issued by a
keyboard as Cntl+z and it takes three escape characters to
drop into command mode from logging mode. My
modification to the CONFIG.TXT file contents is
represented by the 2, which tells the OpenLog firmware to
come up in command mode instead of logging mode.
Since we want to manipulate the microSD card from a
PC using the onboard FTDI USB portal, I left the verbose
and echo settings at their defaults. I’ve already done all of
the necessary preliminary work of defining the I/O pins
and activating the necessary PIC32MX575F512H
peripherals. So, let’s fire up
the electronics that
support the OpenLog and
see if the code works.
Manual Mode
While we are
operating the OpenLog in
manual mode, we will use
the Serial Input/Output
Monitor application that
comes standard with the
CCS C Compiler to issue
commands and capture
the results.
Our OpenLog
firmware will come up in
command mode. Our
PIC32MX575F512H
firmware swallows up the
initial prompt to make sure
the OpenLog hardware is
ready to rock. So, the first
command I will issue is the
RESET command, which should return a prompt. As you
can see in Screenshot 1, we’ve had a good start.
Everything sent and received from the OpenLog is visible
in ASCII and hexadecimal form. Once I received a
prompt, I entered a character to reveal the available
commands.
The goal of having this view is to note the characters
that surround the data. When we go “microcontroller
automatic,” we will need to filter out the characters that
are not part of the data we wish to retrieve. For example,
note the carriage return/line feed characters before the
0x3E prompt in Secreenshot 2. Keep that
in mind as you examine the code we’re
about to write.
Initializing the
microSD Hardware
The OpenLog was originally
designed to be an Arduino accessory. In
our case, the OpenLog hardware is under
the control of a PIC32MX575F512H,
which has access to the ATmega’s RESET
pin. Before attempting to issue
commands via firmware, the
PIC32MX575F512H needs to know if the
OpenLog hardware is functional and if a
functional microSD card is mounted in
the OpenLog’s socket. There is one sure
fire way to get the ATmega’s attention
70 October 2015
Post comments on this article and find any associated files and/or downloads at www.nutsvolts.com/
index.php?/magazine/article/october2015_DesignCycle.
■ Screenshot 1. Things are good. The OpenLog firmware is communicating
with the Serial Input/Output Monitor application running on my Lenovo
laptop by way of the PIC32MX575F512H.
■ Schematic 2. This too is a
minimal implementation of
the FTDI FT232RL. Again,
the LEDs are nice to have,
but they are optional.