View previous topic :: View next topic |
Author |
Message |
buneri
Joined: 23 Aug 2007 Posts: 14
|
Modbus protocol creating trouble for 16f628A chip |
Posted: Thu Sep 27, 2007 12:47 am |
|
|
I have used the 16f877A chip for modbus protocol by using ccs driver modbus.c, it works fine!
Bur when i used 16f628A chip for that purpose the serial port is creating problem. What should i change in the driver to be applicable for 16f628A chip.
Any help will be appreciable. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Sep 27, 2007 11:29 am |
|
|
Post the pins that you are using in these #define statements.
Code: |
#define MODBUS_SERIAL_RX_PIN
#define MODBUS_SERIAL_TX_PIN
#define MODBUS_SERIAL_ENABLE_PIN
#define MODBUS_SERIAL_RX_ENABLE
|
Post your compiler version. |
|
|
buneri
Joined: 23 Aug 2007 Posts: 14
|
Modbus 16f628A |
Posted: Thu Sep 27, 2007 10:52 pm |
|
|
Thx for reply!
Compiler Version PCWH 4.020
I m trying for RS232
#define USE_WITH_PC 1
#include <16f628A.h>
#device *=16
#fuses HS,NOLVP, NOBROWNOUT, NOPROTECT, PUT
#use delay(clock=20M)
#define MODBUS_TYPE MODBUS_TYPE_SLAVE
#define MODBUS_SERIAL_RX_BUFFER_SIZE 64
#define MODBUS_SERIAL_BAUD 9600
#ifndef USE_WITH_PC
#define MODBUS_SERIAL_INT_SOURCE MODBUS_INT_RDA
#define MODBUS_SERIAL_TX_PIN PIN_B0 // Data transmit pin
#define MODBUS_SERIAL_RX_PIN PIN_B1 // Data receive pin
//The following should be defined for RS485 communication
#define MODBUS_SERIAL_ENABLE_PIN PIN_C1 // Controls DE pin for RS485
#define MODBUS_SERIAL_RX_ENABLE PIN_C2 // Controls RE pin for RS485
#else
#define MODBUS_SERIAL_INT_SOURCE MODBUS_INT_RDA
#endif |
|
|
adrian
Joined: 08 Sep 2003 Posts: 92 Location: Glasgow, UK
|
Re: Modbus 16f628A |
Posted: Fri Sep 28, 2007 5:36 am |
|
|
buneri wrote: |
#define MODBUS_SERIAL_INT_SOURCE MODBUS_INT_RDA
#define MODBUS_SERIAL_TX_PIN PIN_B0 // Data transmit pin
#define MODBUS_SERIAL_RX_PIN PIN_B1 // Data receive pin
|
Tx is on the wrong pin to use the hardware USART - it should be on B2. Because you have specified the wrong pin, the software USART is configured. |
|
|
|