CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

My Serial Communicate is Not receive

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
thinnawut



Joined: 15 Sep 2006
Posts: 2

View user's profile Send private message

My Serial Communicate is Not receive
PostPosted: Fri Sep 15, 2006 2:05 am     Reply with quote

My module can recieve command or data about 3 Hour first. after 3 hour it cannot recieve all data.

Hel[ me please.
rgd.


---------------------------------------------------------------------------------
#include <16F877.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7,enable=PIN_b5,bits=8,stream=RS485) // Jumpers: 8 to 11, 7 to 12

#define RS485_RX_BUFFER_SIZE 64
#define RS485_USE_EXT_INT TRUE
#include <stdlib.h>
#byte portb = 6 // PORTB Register
#PRIORITY ext,rda
#include <string.h>
#include <input.c>

/*********************** Interupt Serial **********************/
#int_rda
void rs232_isr()

{
string_in[next_in]=fgetc(RS485);
if(strcmp(string_in[next_in],'*')==0){next_in=0;}
if(strcmp(string_in[next_in],'$')==0){input_status=true;}
next_in=next_in+1;
if(next_in==20)next_in=19;
}

/*********************** End Interupt Serial ********************/
void main()
{
enable_interrupts(GLOBAL); // Enable Global Interrupts
enable_interrupts(INT_EXT);
enable_interrupts(INT_RDA); // Enable External Interrupts
set_tris_b(0x01); // Set TRISB RB1-RB7 output, RB0 input
set_tris_a(0);
set_tris_d(0);

while(TRUE) {}
}
Ttelmah
Guest







PostPosted: Fri Sep 15, 2006 2:39 am     Reply with quote

You set interrupt priority, but only show one interrupt.
Add 'errors' to your S232 setup line. If something else (not shown), such as the 'ext' handler, prevents the serial bing handled in time, without this, the UART will lockup.
Set the tick box 'Disable HTML in this post', when posting code, otherwise parts of it will not be visible (such as what files you are including).
You have set 'RS485_USE_EXT_INT' to true, which means "don't use the RS232 hardware", yet the code you show is to use this hardware...
String compare functions, are quite slow, if the string has any length. When the buffer fills, what is ensuring that the string terminator is still present?. Avoid doing this sort of work in the interrupt handler (this may well be what is hanging the UART). Check the individual _character_, not the whole string.

Best Wishes
thinnawut



Joined: 15 Sep 2006
Posts: 2

View user's profile Send private message

I am no clear.
PostPosted: Mon Sep 18, 2006 12:48 am     Reply with quote

Sorry.If you have some Examp I will it beter. I m not clear.
Thanks.
rgd.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group