arloedx
Joined: 21 Aug 2009 Posts: 15 Location: Texas
|
RS485 Transmitter sending extra data |
Posted: Wed Aug 26, 2009 10:30 am |
|
|
Hello,
I am using the rs485.c library to send data. I have two PIC18f252 and two MAX485 chips. I can send data but additional data is being sent. For example if I send the character 'A', the characters 'AH' are sent. Does anyone have an Idea how to correct this? My code is below. Thanks in advance.
Code: |
#include <18f252.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=10000000)
//#use rs232(baud=9600,xmit=PIN_C6, rcv=PIN_C7)
#define LCD_RS_PIN PIN_B0
#define LCD_RW_PIN PIN_B1
#define LCD_ENABLE_PIN PIN_B2
#define LCD_DATA0 PIN_B4
#define LCD_DATA1 PIN_B5
#define LCD_DATA2 PIN_B6
#define LCD_DATA3 PIN_B7
#include <lcd2.h>
#define RS485_RX_BUFFER_SIZE 64
#define RS485_USE_EXT_INT FALSE
#define RS485_ID 0x01
#define RS485_ENABLE_PIN PIN_C5
#define RS485_TX_PIN PIN_C6
#define RS485_RX_PIN PIN_C7
#include <rs485.c>
#include <stdlib.h>
void LCD_CHECK();
void state(unsigned char s);
void frequency(unsigned char frc);
int RS485_DEST_ID;
void LCD_CHECK()
{
lcd_gotoxy(1,1);
printf(lcd_putc, "System Ready");
delay_ms(500);
printf(lcd_putc,"\f");
}
int8 size=1;
int i, max = 5 ;
int8 bufsend[5] = {'A','B','C','D','E'};
int *pointer;
void main()
{
output_high(RS485_ENABLE_PIN);
rs485_init();
lcd_init();
LCD_CHECK();
while(true)
{
RS485_DEST_ID = 0x09;
for(i=0; i<3; i++)
{
pointer = &bufsend[i];
rs485_send_message(RS485_DEST_ID, size, pointer);
printf(lcd_putc,"\fSent: %c", bufsend[i]);
delay_ms(400);
}
RS485_DEST_ID = 0x07;
for(i=3; i<max; i++)
{
pointer = &bufsend[i];
rs485_send_message(RS485_DEST_ID, size, pointer);
printf(lcd_putc,"\fSent: %c", bufsend[i]);
delay_ms(400);
}
delay_ms(1000);
}
}
|
|
|