Serial data Communication problem!
2004-04-13 by ereihani
HI!
Is it the right way of transmitting data via serial port?
I mean I put my data in UDR then in INT routine put the next data
and so on.
I use Visual Basic for reading data but I don't get any data there!
I am also suspicious to my visual Basic program too!
Please guide me in both cases.
Regards,
Ehsan reihani
The C Program
------------------------------------------------------------
#include <mega16.h>
#include <delay.h>
int i=0;
interrupt [USART_DRE] void USART_DATA_REGISTER_EMPTY(void)
{
UDR=i;
PORTA=0xff;
}
void main(void)
{
UBRRL=0x0C;
UCSRB|=0x18;
UCSRC=0x86;
PORTA=0x00;
for(i=0;i<=9;i++) UDR=i;
}
---------------------------------------------------------------
The Visual Basic Program
'In VB I have used a mscomm and a command in my form
Private Sub Command1_Click()
Dim dr As Variant
MSComm1.CommPort = 1
MSComm1.OutBufferSize = 17
MSComm1.InBufferSize = 10
MSComm1.PortOpen = True
MSComm1.Handshaking = comRTS
MSComm1.RTSEnable = True
MSComm1.InputMode = comInputModeText
MSComm1.InputLen = 0
dr = MSComm1.Input
Text1.Text = dr
MSComm1.PortOpen = False
End Sub