# how do I output through GPIO pins instead of RS232 from a Z8 Encore MCU?

I'm currently learning about MCUs in school (read: n00b) and I'm trying to fool around with the equipment at home. Problem is that I only have a netbook and don't have any serial IOs on it, so I have to make due with a USB connection. The MCU is a Z8 Encore! 64K Series Z8F6423. But to hook up a output i have to hook it up to a filter board that my school built (i think), which I have photographed and uploaded to the album below. To power the filter board, it's hooked up to a Spartan-3 FPGA board which also is in the picture.

I'm trying to program the MCU to output a simple "Hello World!", but instead of sending it through UART0, I'm trying to send it through the GPIOs, into another board my school made, which then should output it through a USB cable. The USB should be visible in the pictures here: album

My question is simply, how do I send the output through the GPIO to the USB, which then should show up in PuTTY on my laptop? Is this possible for you to answer, or do you have to know the exact schematics of the filter board? Based on the code below, it is sending the signal through the UART0, but where should I send it if I want it to go through the GPIO?

The program is as simple as this:

#include <eZ8.h>
#include <sio.h>

void main() {
init_uart(_UART0_DEFFREQ,_DEFBAUD); // set-up UART0 to 57600, 8n1
printf("hello world\n");
do {} while (1 != 2); // stay here forever
}

-
You'll need a library for that particular MCU that does "software UART" or "bit-banging". While you can write this yourself, you'll have to lean about timers and the RS232 protocol; I'd estimate it taking about a week for someone to learn from scratch. –  pjc50 Jan 17 '13 at 12:56
OK, so I guess that if there is an answer to this question, it's going to be more advanced than just changing from UART0 to UART1 or something similar then. –  cazyius Jan 17 '13 at 13:18
Well, there is a UART1, I think; zilog.com/… –  pjc50 Jan 17 '13 at 13:54
Writing a software UART is of course far more difficult than using an on-chip hardware peripheral. Even experienced developers only do that as a last resort. It will be a painful but educational experience. –  Lundin Jan 17 '13 at 14:25
If you just want to experiment and solve the problem quickly, why not get a simple USB to RS-232 converter? Sure, it won't work as well as a PCI or PCI-E card, but it will let you use your terminal program to see what text the microcontroller is sending let's face it: If you want to do any serious work, there's no way to avoid having a serial port on your computer, so you'll need it sooner or later. –  AndrejaKo Jan 17 '13 at 17:15

You would need a USB to serial converter. The USB end will go into your netbook and the serial end will to to the UART on your board. That way when the UART on the board transmits, it will appear in PUTTY or any other serial terminal program running on your netbook.

-
This might not be the answer to my question, but this is the answer I'm going to go with. Based on what I've found out, it's way to much hassle to try and find a way to get the message through the GPIO ports instead of just purchasing a USB-to-serial converter. Thanks! –  cazyius Jan 17 '13 at 19:04
@cazyius it is all up to you to concentrate on developing a mechanism to communicate with your netbook or concentrate of other parts of the problem. Bit-banging USB takes a lot of efforts so unless (or until) it is your primary goal with Z8, use a USB-Serial adapter. There are many available on ebay that have TTL level outputs at the UART end. –  Chetan Bhargava Jan 17 '13 at 19:09

There's an app note on how to do software UART on any GPIO: http://www.zilog.com/docs/z8encore/appnotes/an0147.pdf

But it does look like that chip has a second UART, UART1. Not clear what it's wired to on your board.

-
being so inexperienced as I am, I'm afraid that writing a software UART might be a little to complicated for me. I did try switching to UART1, and the compiler did not note any errors, but upon running the program on the MCU, I didn't get any signal out to PuTTY. –  cazyius Jan 17 '13 at 14:31
What are the UART1 pins wired to? –  pjc50 Jan 17 '13 at 14:53
I have no idea, there's only one serial port, and I don't really know where to look to find that out? –  cazyius Jan 17 '13 at 18:29
@pjc50 I believe that OP wants to bit-bang USB so that he can communicate with his netbook that doesn't have a serial port. –  Chetan Bhargava Jan 17 '13 at 19:19