View previous topic :: View next topic |
Author |
Message |
maq
Joined: 13 Aug 2009 Posts: 2
|
problem in SERIAL - ISR EACH TIME REQUIRE MANUALY RESET |
Posted: Tue Aug 25, 2009 6:15 am |
|
|
I M DOING SERIAL COMM. B/W 2 PIC18F USING HARDWare RS232.
I HAVE A PROBLEM WHEN SENDING SERIAL DATA SECOND TIME .
IT DOES NOT RESPONSE WELL AS IN FIRST TIME WHEN I POWER IT.
EACH TIME I HAVE TO RESET THR PIC MANUALLY.
THEN IT RESPONSE WELL..
I ALSO CLEARED THE SERIAL INTERUPT AT THE END OF ISR .
BUT DIDNOT FIND ANY RESPONSE(SAME PROBLEM)
ANY BODY HOW TO DO????? |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Tue Aug 25, 2009 6:58 am |
|
|
You will get a better response when you learn the basic rules of how to behave on a forum.
Don't start a new thread for the same or related questions. This is a double post from http://www.ccsinfo.com/forum/viewtopic.php?t=39998 |
|
|
maq
Joined: 13 Aug 2009 Posts: 2
|
|
Posted: Tue Aug 25, 2009 8:58 pm |
|
|
Thanx for your response.
I use this code to send data to hyper terminal.
It run well but when I receive data from hyperterminal. It halt.
I check on scope. It does not send any data.
I have to reset it each time.
Here is code:
Code: |
#include <18F4550.H>
#include <string.h>
#fuses HS, NOWDT, BROWNOUT, NOPUT, NOLVP
#use delay(clock=20000000) // 4 MHz OSC
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
////////////////// INTERRUPT FUNCTION /////////////////
#INT_RDA
void serial_isr()
{
int i=0;
char ack[3];
char comp[3]="OK";
gets(ack);
if(strncmp(ack,comp,2)==0)
{
printf("i m right");
do
{
output_high(PIN_D0);
delay_ms(100);
output_low(PIN_D0);
delay_ms(100);
i++;
}while(i<10);
}
else
{
printf("i m wrong");
do
{
output_high(PIN_D1);
delay_ms(100);
output_low(PIN_D1);
delay_ms(100);
i++;
}while(i<10);
}
clear_interrupt(INT_RDA);
}
/////////////////// MAIN FUNCTION /////////////////
void main()
{
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
SET_TRIS_B( 0x26 );
set_tris_D(0x00);
///////////////// for communication with slave1.
output_low(PIN_D0);
output_low(PIN_D1);
while(1)
{
if(input(PIN_B5)==0)
{
puts("CMD");
output_high(PIN_D3);
while(input(PIN_B5)==0);
}
//output_low(PIN_D2);
output_low(PIN_D3);
}
}
|
Guide me...... |
|
|
|