THE BOTTOM LINE ... DOES IT WORK?
When I plugged that USB cable into the MCP2200 USB-to-UART converter, I was confronted by the usual “let’s install
a new USB device” jargon. After the driver automatons did
their thing, I was granted access to a VCP (Virtual Comm Port)
and a HID device in the guise of our MCP2200 converter.
The easiest way to put some test code together is to
call out the CCS C compiler. I whipped out the CCS C
compiler 16-bit Project Wizard and quickly built a code
shell for the PIC24FJ128GA006. Here are the
Configuration Fuse settings which the Project Wizard
generated and placed in the nv-ccs-mcp2200-project.h file:
//No Watch Dog Timer
//Code not protected from
//Program memory not write
//No Debug mode for ICD
//ICD uses PGC2/PGD2 pins
//Watch Dog Timer in Window
//Watch Dog Timer PreScalar
//Watch Dog Timer PostScalar
//Internal External Switch
//Over mode disabled
//Primary Oscillator with PLL
//Clock Switching is
//disabled, fail Safe clock
//monitor is disabled
//OSC2 is clock output
//Crystal osc <= 4mhz for
//PCM/PCH , 3mhz to 10 mhz
The CCS C compiler is a wonderful PIC compiler.
I was able to put together this simple converter test
program in less than 15 minutes:
setup_spi( FALSE );
setup_spi2( FALSE );
printf(“THE MCP2200 IS NOW PART OF
YOUR DESIGN CYCLE!!\r\n”);
The converter allows us to code our applications just
as if they were using that SP3232 we replaced in the
design. The proof is in the pudding and the pie crust is
filled with Screenshot 4.
NO PORKY PIG QUITE JUST YET
As Jason Aldean says about all night redneck parties ...
“We ain’t done yet.” I’ve got a Scooby-Doo ending for
you. I’m going to leave you with some C30 source code
that will address the LCD and make the RX LED on your
converter blink with joy:
U2BRG = 104; //9600 bps
U2MODE = 0x8000; //enable the UART
U2STAbits.UTXEN = 1; //enable TX
■ SCREENSHOT 2. To quote Joe Friday, “All we want
are the facts, ma’am.” That’s pretty much all that the
MCP2200 Configuration Utility really wants too.
The little initUART code snippet is all that’s needed to
configure the PIC24FJ128GA006’s UART to drive at 9600 bps.
If you’re wondering why
the MCP2200’s RX LED
would flash instead of
its TX LED, the
MCP2200 is on the
USB side of things. As
far as the MCP2200
is concerned, the
transmitting and it is
receiving. The receive/
reported by the
MCP2200’s RX and
TX LEDS is not the
status but its own status.
■ SCREENSHOT 3. The
only value I changed
for our design was
the baud rate which
defaults to 19200 bps.