View previous topic :: View next topic |
Author |
Message |
Oblivion
Joined: 23 Sep 2010 Posts: 13
|
Need help with Pic16F877 Modbus communication |
Posted: Thu Sep 23, 2010 7:13 am |
|
|
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
|
|
Posted: Thu Sep 23, 2010 9:33 am |
|
|
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
|
|
Posted: Fri Sep 24, 2010 12:06 am |
|
|
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
|
|
Posted: Sat Sep 25, 2010 10:02 am |
|
|
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 |
|
|
|