char uart_rd;
void main() {
ADCON1 |= 0x0F; // Configure AN pins as digital
CMCON |= 7; // Disable comparators
UART1_Init(19200); // Initialize UART1 module at 9600 bps
Delay_ms(100); // Wait for UART 1module to stabilize
UART1_Write_Text("Start");
UART1_Write(13);
UART1_Write(10);
while (1) { // Endless loop
if (UART1_Data_Ready()) { // If data is received,
uart_rd = UART1_Read(); // read the received data,
UART1_Write(uart_rd); // and send data via UART1
}
}
}
UART1_Init(19200);
Means that you are using 19200 Baud Rate
UART1_Write_Text("Start");
//Means you are sending the "Start" to the Serial Pins of the Controller
UART1_Write(13);
//Means you are using Carriage return in short "ENTER" key of keyboard whose ASCII value is 13
UART1_Write(10);
//Means you are using Line Feed whose ASCII value is 10
//Search Google to see the difference b/w Line Feed and Carriage Return
if (UART1_Data_Ready()
//The above Statement check whether u are receiving any data from the serial pins or not
//If you are getting some data then following commands will get executed
uart_rd = UART1_Read(); // read the received data,
//Whatever character u received is stored in the uart_rd variable
UART1_Write(uart_rd); // and send data via UART1
//And What ever variable you read is sent to the Serial PORT Again
Open Hyper-Terminal in Windows
Connect the Controller with appropriate logic conversion(MAX232) with the serial port of computer
then POWER-ON the Controller
You will get a "Start" on the hyperterminal 'don't forget to set the baud rate of PC's Hyper-Termianl
after that
whatever you type on the Hyper-Terminal you will be able to see that..
Hope this explanation helps u
Regards
Arun Sharma
whenever the UART1_Write_Text is used, then some problem is there, but the program is echoing the character i sent
The usage of UART1_Write_Text is the problem, not getting the start message and whenever i use UART1_Write_Text , some problem in sending
UART1_Write_Text("Start\n\r");
UART1_Write_Text("Start\n");
UART1_Write_Text("Start");
UART1_Write(13);
UART1_Write(10);
I prefer PuTTY over Hyperterminal.
PuTTY Download Page
I find it a lot more versatile and supports many more features including SSH
The newline or return characters maybe cause some issue:
Try
Code:UART1_Write_Text("Start\n\r");
Or
Code:UART1_Write_Text("Start\n");
Instead Of:
Code:UART1_Write_Text("Start"); UART1_Write(13); UART1_Write(10);
BigDog
UART1_Write_Text("Start\n");
UART1_Write_Text("Start\n\r");
in serial communication with C#, will these produce problems ?
yes its working,
Thanks dear,
char uart_rd;
void main() {
ADCON1 |= 0x0F; // Configure AN pins as digital
CMCON |= 7; // Disable comparators
UART1_Init(9600); // Initialize UART1 module at 9600 bps
Delay_ms(100); // Wait for UART 1module to stabilize
UART1_Write_Text("Start");
UART1_Write(13);
UART1_Write(10);
while (1) { // Endless loop
if (UART1_Data_Ready()) {
uart_rd = UART1_Read(); // read the received data,
switch (uart_rd ) // If data is received,
{
case 1:
portb.f1=1;
case 2:
portb.f2=1;
}
// UART1_Write(uart_rd); // and send data via UART1
}
}
}
can we use something like the below in mikroC ?
Code:
char uart_rd;
void main() {
ADCON1 |= 0x0F; // Configure AN pins as digital
CMCON |= 7; // Disable comparators
UART1_Init(9600); // Initialize UART1 module at 9600 bps
Delay_ms(100); // Wait for UART 1module to stabilize
UART1_Write_Text("Start");
UART1_Write(13);
UART1_Write(10);
while (1) { // Endless loop
if (UART1_Data_Ready()) {
uart_rd = UART1_Read(); // read the received data,
switch (uart_rd ) // If data is received,
{
case 1:
portb.f1=1;
case 2:
portb.f2=1;
}
// UART1_Write(uart_rd); // and send data via UART1
}
}
}
char uart_rd;
void main() {
trisb=0;
portb=0;
ADCON1 |= 0x0F; // Configure AN pins as digital
CMCON |= 7; // Disable comparators
UART1_Init(9600); // Initialize UART1 module at 9600 bps
Delay_ms(100); // Wait for UART 1module to stabilize
UART1_Write_Text("Start");
UART1_Write(13);
UART1_Write(10);
while (1) { // Endless loop
if (UART1_Data_Ready()) {
uart_rd = UART1_Read(); // read the received data,
switch (uart_rd ) // If data is received,
{
case 1:
portb.f1=1;
delay_ms(500);
case 2:
portb.f2=1;
delay_ms(500);
}
// UART1_Write(uart_rd); // and send data via UART1
}
}
}
case 1:
portb.f1=1;
delay_ms(500);
break;
case 2:
portb.f2=1;
delay_ms(500);
break;
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?