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

Selection for MODBUS ADDRESS and MODBUS_SERIAL_BAUD

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



Joined: 04 Nov 2012
Posts: 15

View user's profile Send private message

Selection for MODBUS ADDRESS and MODBUS_SERIAL_BAUD
PostPosted: Thu Sep 18, 2014 2:37 am     Reply with quote

Hi,

I am using ex_modbus_slave.c file of CCS compiler version 4.119. The code working fine. But I need to provide the selection of Baud rates for communication. Instead of fixed baud rate I need flexible baud rates which can be selected by end user.

Code:

/////////////////     Setting Modbus parameters      ////////////////////

/////////////////////////////////////////////////////////////////////////

#define MODBUS_TYPE                       MODBUS_TYPE_SLAVE       
#define MODBUS_SERIAL_TYPE                MODBUS_RTU           
#define MODBUS_SERIAL_INT_SOURCE          MODBUS_INT_RDA             
#define MODBUS_SERIAL_RX_BUFFER_SIZE      64               
//#define MODBUS_SERIAL_BAUD              9600                     
#define MODBUS_SERIAL_RX_PIN              PIN_C7                 
#define MODBUS_SERIAL_TX_PIN              PIN_C6                   
#define MODBUS_SERIAL_ENABLE_PIN          Pin_C5               
#define MODBUS_SERIAL_RX_ENABLE           Pin_C5                 

#include <modbus.c>

#define MODBUS_ADDRESS       Channel_No   
#define MODBUS_SERIAL_BAUD   Baud_Rate     




It gives duplicate define warning. Please advise how to assign multiple baud rate options in this code.

Thanks,
Paddy
Ttelmah



Joined: 11 Mar 2010
Posts: 19516

View user's profile Send private message

PostPosted: Thu Sep 18, 2014 2:57 am     Reply with quote

You don't directly.

You build the code to handle one rate (19200bps, or 9600bps say).
Then use the 'set_uart_speed' command to select the rate you actually want to run.

So you have a command from the keyboard, or an external DIP switch (for example), that chooses from perhaps four rates, and then just call set_uart_speed(xxxx), to chose the rate.
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