OK. This is driving me crazy.
Here's what I've done so far:
Sample C++ from my PC to VFD:
Code: Select all
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
DCB dcb;
HANDLE hCom;
hCom = CreateFile("COM1",GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL);
GetCommState(hCom, &dcb);
dcb.BaudRate = CBR_19200; // set the baud rate
dcb.ByteSize = 8; // data size, xmit, and rcv
dcb.Parity = NOPARITY; // no parity bit
dcb.StopBits = ONESTOPBIT; // one stop bit
SetCommState(hCom, &dcb);
DWORD dw;
char buffer[256];
// set up screen options:
buffer[0] = 0xfe;
// auto line wrap off
buffer[1] = 68;
WriteFile(hCom,buffer,2,&dw,NULL);
// auto scroll off
buffer[1] = 82;
WriteFile(hCom,buffer,2,&dw,NULL);
// turn off underline cursor
buffer[1] = 75;
WriteFile(hCom,buffer,2,&dw,NULL);
// turn off blinking cursor
buffer[1] = 84;
WriteFile(hCom,buffer,2,&dw,NULL);
// clear the screen
buffer[1] = 88;
WriteFile(hCom,buffer,2,&dw,NULL);
lstrcpy((LPTSTR)buffer,"Hello, World!");
WriteFile(hCom,buffer,lstrlen(buffer),&dw,NULL);
CloseHandle(hCom);
return 0;
}
Works perfect! (looks cool as hell, too

!)
Next step, CodeViewAVR to program uC.
Here's the code I came up with:
Code: Select all
#define RXEN 0x04
#define RXC 0x07
#define TXEN 0x03
#define UDRE 0x05
void TransmitByte( unsigned char data );
#include <90s8515.h>
// Standard Input/Output functions
#include <stdio.h>
// Declare your global variables here
void main(void)
{
PORTA=0x00;
DDRA=0x00;
PORTB=0x00;
DDRB=0x00;
PORTC=0x00;
DDRC=0x00;
PORTD=0x00;
DDRD=0xff;
TCCR0=0x00;
TCNT0=0x00;
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
GIMSK=0x00;
MCUCR=0x00;
TIMSK=0x00;
UCR=0x08;
UBRR=0x0B;
ACSR=0x80;
TransmitByte(0xfe);
TransmitByte(68);
TransmitByte(0xfe);
TransmitByte(82);
TransmitByte(0xfe);
TransmitByte(75);
TransmitByte(0xfe);
TransmitByte(84);
TransmitByte(0xfe);
TransmitByte(88);
TransmitByte('H');
TransmitByte('e');
TransmitByte('l');
TransmitByte('l');
TransmitByte('o');
TransmitByte(',');
TransmitByte(' ');
TransmitByte('W');
TransmitByte('o');
TransmitByte('r');
TransmitByte('l');
TransmitByte('d');
TransmitByte('!');
}
void TransmitByte( unsigned char data )
{
while ( !(USR & (1<<UDRE)) )
; /* Wait for empty transmit buffer */
UDR = data; /* Start transmittion */
}
Now, to make sure it works, I hooked my development board to COM2 of my PC, and watched output with HyperTerminal. Perfect. Works like a charm. Each time I reset the uC, I see the bytes go to HyperTerminal.
Last step, hook uC to VFD.
1st attempt: using DB9 from development board to VFD (just pulled out of PC COM2 and plugged into VFD).

No response from VFD
2nd attempt: using 2 wires, from PD0 and PD1 on uC to Rx/Tx on VFD (with jumpers set to RS-232).

No response from VFD
What am I doing wrong?
Does anyone see anything I did wrong. Any help is appreciated.
Thx.