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 support@ccsinfo.com

Modbus Master does not receive messages from slave

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



Joined: 16 May 2013
Posts: 1

View user's profile Send private message

Modbus Master does not receive messages from slave
PostPosted: Fri May 24, 2013 9:06 am     Reply with quote

Hi everyone!
I'm implementing a Modbus RTU communication in a PIC18f4520, actually I'm using modbus CCS library. When i send a messge, the slave receive it, and does its work, but when the slave respond to the master, the master is not able to receive the massage.(for any function the exception always is TIMEOUT=12)
I didn't make any change on the library code

Code:
#include <main.h>
#include "LCD.c"

#define MODBUS_TIMER_USED                    MODBUS_TIMER_T1
#define MODBUS_PROTOCOL                      MODBUS_PROTOCOL_SERIAL
#define MODBUS_TYPE                          MODBUS_TYPE_MASTER
#define MODBUS_SERIAL_ENABLE_PIN             PIN_C5       
#define MODBUS_SERIAL_RX_ENABLE              PIN_C4         
#define MODBUS_SERIAL_BAUD                   19200
#define MODBUS_SERAIL_RX_BUFFER_SIZE         64
#define MODBUS_TIMER_UPDATE                  MODBUS_TIMER_ISR
#define MODBUS_SERIAL_INT_SOURCE             MODBUS_INT_RDA
#include <modbus.c>
#define MODBUS_SLAVE_ADDRESS                 0x64
#use FAST_IO(D)
#use FAST_IO(A)

void main()
{
   unsigned char flags = 0;
   unsigned long int Frec = 290;
   float FrecLCD;
   setup_timer_3(T3_DISABLED | T3_DIV_BY_1);
   
   lcd_init();
   modbus_init();
   SET_TRIS_D(0x0F);


   while(1)
   {
//================================================================== 
// read regieter 8451
      if( ( (0x01&flags) == 0x00 ) && ( 0x01 == (0X01&INPUT_D()) ) )
      {
         delay_ms(8);
         if((modbus_read_holding_registers(MODBUS_SLAVE_ADDRESS,8451,1)))
         {
            FrecLCD = (float)Frec/10;
            printf(lcd_putc,"\fFrec: %2.1f \n", FrecLCD );
            FrecLCD = (float)*(&modbus_rx.data[2]);
            printf(lcd_putc,"%2.1f Hz Exep. %d", FrecLCD , modbus_rx.error);
         }
         else
         {
            printf(lcd_putc,"\fExep. %d", modbus_rx.error);
         }
           
            flags ^= 0x01;
         
       
      }

      if( ( (0x01&flags) == 0x01 ) && ( 0x00 == (0X01&INPUT_D())))
      {
         delay_ms(8);
         //lcd_putc("\f =)");
         flags ^= 0x01;
      }
   }
}


I've been working on this for 3 days and i can't get it.

in advance thank you very much fory your help.
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