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

Need help with Pic16F877 Modbus communication

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



Joined: 23 Sep 2010
Posts: 13

View user's profile Send private message

Need help with Pic16F877 Modbus communication
PostPosted: Thu Sep 23, 2010 7:13 am     Reply with quote

Hello everyone. I am new in this forum...
I searched the forum as much as i can for my problem but yet i cannot solve it. So if anyone helps me with this, i'll be gratefull...
I want to communicate with Pic16F877 via RS232. I have ex_modbus_slave.c and ex_modbus.c example files. There are somethings i want to do. I need to change the baud rate at the runtime. As i can find, i should use "setup_uart()" or "set_uart_speed()" functions to do that. When i try the use the first one, i must change the data transmit pin B0 to C7 and data receive pin B1 to C6 (because "setup_uart()" only works with them). Like this, my hardware fails. I cannot communicate with C6 and C7 pins (because of the "int_ext" interrupt)... And the other problem; i don't know where i must write the "setup_uart()" function in the program. I am having errors when i try it and i couldn't be able to fix most of them...
Can anyone help me with my problems? Or at least give me some advice?
Thanks for your concern....
FFT



Joined: 07 Jul 2010
Posts: 92

View user's profile Send private message

PostPosted: Thu Sep 23, 2010 9:33 am     Reply with quote

Hi,

I think you should add the setup_uart() into modbus_init() function.
Actually you don't need setup_uart function, you can do what you want using something like set_uart_speed(9600, MODBUS_SERIAL);

Why do you use ext_int interrupt in uart modbus? Configure it as #define MODBUS_SERIAL_INT_SOURCE MODBUS_INT_RDA
Oblivion



Joined: 23 Sep 2010
Posts: 13

View user's profile Send private message

PostPosted: Fri Sep 24, 2010 12:06 am     Reply with quote

Thanks for your concern...

Why should I use MODBUS_INT_RDA instead of MODBUS_INT_EXT ? I guess I didn't understand that part yet. Also when I directly write MODBUS_INT_RDA instead of MODBUS_INT_EXT, I got lots of errors. So that mustn't be like that I guess. Can you explain it in more details?

Thank you...
RVaughn13



Joined: 09 Feb 2006
Posts: 13
Location: Santa Fe, Texas

View user's profile Send private message Visit poster's website

PostPosted: Sat Sep 25, 2010 10:02 am     Reply with quote

Have you checked the modbus examples in the ex_modbus_master.c (in the examples directory under the PICC software installation)? I believe there are 2 or 3 examples of using modbus.
I have several modbus installations but I write my own drivers and do not use the built in functions. I know people that use the built in functions and have no problems with them.
Good Luck with your project!
Rick
_________________
--Rick
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