void interrupt(){
if(PIR1.RCIF){
MAX_CONTROL=0;
if ((RCSTA.OERR )&& (RCIE_bit==1)){
RCSTA.CREN = 0;
Nop();
Nop();
RCSTA.CREN = 1;
garbage=RCREG;
garbage=RCREG;
}
else{
input_string[index]=RCREG;
if(input_string[index]==59){
flag=1;
}
index++;
if((index>12) && (input_string[12] != 59)) index=0;
}
PIR1.RCIF=0;
}
if(flag==1){
if((input_string[0]== 82) && (input_string[1]==59)){
MAX_CONTROL = 1;
Delay_ms(1);
UART1_Write(FND_0+65);
UART1_Write(FND_1+65);
UART1_Write(FND_2+48);
UART1_Write(FND_3+48);
UART1_Write(FND_4+65);
UART1_Write(FND_5+65);
UART1_Write(FND_6+48);
UART1_Write(FND_7+48);
UART1_Write(FND_8+48);
UART1_Write(FND_9+48);
UART1_Write_Text("\r\n");
Delay_ms(1);
MAX_CONTROL = 0;
}
if((input_string[0]== 87) && (input_string[11]==59)){
write=1;
}
index=0;
flag=0;
}
if(sent==1){
MAX_CONTROL = 1;
UART1_Write_Text("\r\nOK");
Delay_ms(1);
MAX_CONTROL = 0;
sent=0;
}
if(INTCON.TMR0IF){
TMR0L = TIMER_START_VALUE;
TMR0H = TIMER_START_VALUE_1;
TMR0IF_bit = 0;
}
if(prg_key==1){
blink++;
if(blink>500) blink=0;
last++;
}
}
I tested it using USART terminal provided with mikroc. It is working fine. means controller is able to accept and send the data. Then i tasted it on another laptop with same USART terminal. It worked fine.
void interrupt()
{
if(PIR1.RCIF)
{
MAX_CONTROL=0;
if ((RCSTA.OERR )&& (RCIE_bit==1))
{
RCSTA.CREN = 0;
RCSTA.CREN = 1;
garbage=RCREG;
garbage=RCREG;
}
else
{
input_string[index]=RCREG;
if(RCREG == ';') flag=1;
index++;
if((index>12) && (input_string[12] != ';')) index=0;
}
PIR1.RCIF=0;
}
if(flag==1)
{
if((input_string[0]== 'R') && (input_string[1]== ';'))
{
MAX_CONTROL = 1;
Delay_ms(1);
UART1_Write(FND_0+'A');
UART1_Write(FND_1+'A';
UART1_Write(FND_2+'0';
UART1_Write(FND_3+'0');
UART1_Write(FND_4+'A');
UART1_Write(FND_5+'A');
UART1_Write(FND_6+'0');
UART1_Write(FND_7+'0');
UART1_Write(FND_8+'0');
UART1_Write(FND_9+'0');
UART1_Write_Text("\r\n");
Delay_ms(1);
MAX_CONTROL = 0;
}
if((input_string[0]== 'W') && (input_string[11]== ';')) write=1;
index=0;
flag=0;
if(sent==1)
{
MAX_CONTROL = 1;
UART1_Write_Text("\r\nOK");
Delay_ms(1);
MAX_CONTROL = 0;
sent=0;
}
if(INTCON.TMR0IF)
{
TMR0L = TIMER_START_VALUE;
TMR0H = TIMER_START_VALUE_1;
TMR0IF_bit = 0;
}
if(prg_key==1)
{
blink++;
if(blink>500) blink=0;
last++;
}
}
void main()
{
}
void interrupt(){
if(PIR1.RCIF){
MAX_CONTROL=0;
input_string[index]=RCREG;
if(input_string[index]==59) flag=1;
index++;
PIR1.RCIF=0;
}
if(INTCON.TMR0IF){
TMR0L = TIMER_START_VALUE;
TMR0H = TIMER_START_VALUE_1;
TMR0IF_bit = 0;
}
if(prg_key==1){
blink = ~blink;
last++;
}
}
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?