|
|
View previous topic :: View next topic |
Author |
Message |
thinnawut
Joined: 15 Sep 2006 Posts: 2
|
My Serial Communicate is Not receive |
Posted: Fri Sep 15, 2006 2:05 am |
|
|
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
|
|
Posted: Fri Sep 15, 2006 2:39 am |
|
|
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
|
I am no clear. |
Posted: Mon Sep 18, 2006 12:48 am |
|
|
Sorry.If you have some Examp I will it beter. I m not clear.
Thanks.
rgd. |
|
|
|
|
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
|