The problem seemed to be in the initial wake-up speed of
the PIC32MX’s SPI clock. I lowered the SPI clock speed
from 10 MHz to 4 MHz, which solved the “dead display”
problem. Here’s the updated SPI configuration code that
runs in the init() function:
■ Screenshot 2.
Just in case
you're not from
{
SPI2BUF = 0x00;
//send 0x00
while(SPI2STATbits.
SPIRBF == 0);
//wait until bus
//cycle complete
dummybite = SPI2BUF;
while(SPI2STATbits.
SPIBUSY == 1);
}
CShi;
}
SPI2CONbits.ON = 0;
//disable SPI2 peripheral
SPI2CONbits.MSTEN = 1; //Master mode
SPI2CONbits.CKP = 0;
//polarity idle low
SPI2CONbits.CKE = 1;
//transmit on active to idle
SPI2CONbits.SMP = 0;
//sample in the middle
SPI2BRG = 0x13;
//4MHz SPI clock
SPI2STATbits.SPIROV = 0;
//clear overflow flag
SPI2CONbits.ON = 1;
//enable SPI2 peripheral
Tennessee, high
cotton means
tall cotton —
and we seem to
be walking in it.
Waking the FT800
Table 5 lists the commands that we can transfer and
execute using the hostCmd function.
SPI Setup
Before we can access the FT800, we must wake it up.
Naturally, before we can throw that bucket of cold water
on it, we must execute the init() function to set up the
PIC32MX’s GPIO, clock, and SPI portal. The PIC32MX
init() function also insures that the CS_N and PD_N
(Power Down) pins are forced to their inactive states.
There are a couple of user-accessable LEDs on the
MX3 that are initialized. If you are new to PIC32MX
programming, one of the most important gotchas to look
out for is the JTAG interface which is enabled by default:
While I was chewing on a piece of elephant, I noticed
that my original SPI setup was not working as designed.
#define CSlo LATGCLR = 0x0200;
//0000 0010 0000 0000
#define CShi LATGSET = 0x0200;
#define PDlo LATBCLR = 0x0020;
//0000 0000 0010 0000
#define PDhi LATBSET = 0x0020;
#define LD4on LATFSET = 0x0001;
//0000 0000 0000 0001
#define LD4off LATFCLR = 0x0001;
#define LD4tog LATFINV = 0x0001;
#define LD5on LATFSET = 0x0002;
//0000 0000 0000 0010
#define LD5off LATFCLR = 0x0002;
CShi; //SPI slave select inactive
PDhi; //power down inactive
LD4off; //utility LEDs on MX3
LD5off;
DDPCONbits.JTAGEN = 0;
I included the lo-hi-on-off mini macros
for clarity. Using the PIC32MX atomic I/O
operations eliminates the need for a
schematic just to identify these particular
I/O pin assignments. The FT800 wake-up
sequence begins by driving the FT800’s PD
pin logically low for 20 mS, and then driving
the PD pin logically high for 20 mS:
■ Table 6. I figured I had nothing to lose, so I plugged these values
into the driver. As it turned out, I was able to continue walking in the
cotton field.
init(); //execute initialize
60 July 2014