|
|
View previous topic :: View next topic |
Author |
Message |
josb86
Joined: 15 Apr 2013 Posts: 8
|
modbus in 16f887 "modbus_phy_layer_rtu.c " this sa |
Posted: Mon Apr 15, 2013 3:15 pm |
|
|
I am trying to implement modbus protocol in a pic16f887. I have the version 4.140 compiler. I use the project wizard option and when I wish to compile the program, it shows a error in the line "#USE TIMER(TIMER=1,TICK=.1ms,BITS=16, ISR)" of "modbus_phy_layer_rtu.c ". This say "line 25(9,47):internal error - contact ccs ppuse"
Code: | #include <v2.h>
#define MODBUS_BUS SERIAL
#define MODBUS_TYPE MODBUS_TYPE_SLAVE
#define MODBUS_SERIAL_TYPE MODBUS_RTU
#define MODBUS_SERIAL_RX_BUFFER_SIZE 64
#define MODBUS_SERIAL_RX_PIN PIN_C7
#define MODBUS_SERIAL_TX_PIN PIN_C6
//#define MODBUS_SERIAL_ENABLE_PIN PIN_
//#define MODBUS_SERIAL_RX_ENABLE PIN_
#define MODBUS_SERIAL_BAUD 9600
#define MODBUS_OUR_ADDRESS 230
#include "modbus.c"
void main()
{ boolean respond = false;
modbus_init();
fprintf(SLAVE_PC, "\n\rReady...");
while(TRUE)
{
while(!modbus_kbhit());
fprintf(SLAVE_PC, "\n\rBus Active");
if((respond = (modbus_rx.address == MODBUS_OUR_ADDRESS)) || modbus_rx.address == 0)
{
fprintf(SLAVE_PC, "\n\rRequest for us");
fprintf(SLAVE_PC, "\n\rFunction: %X", modbus_rx.func);
switch(modbus_rx.func)
{
case 0x01:
if(respond)
{
//read the coils
}
break;
case 0x02:
if(respond)
{
//read discrete inputs
}
break;
case 0x03:
if(respond)
{
//read holding registers
}
break;
case 0x04:
if(respond)
{
//read input registers
}
break;
case 0x05:
break;
case 0x06:
break;
case 0x07:
break;
case 0x08:
if(respond) {modbus_diagnostics_rsp(MODBUS_OUR_ADDRESS,
make16(modbus_rx.data[0],modbus_rx.data[1]),
make16(modbus_rx.data[2], modbus_rx.data[3]));}
fprintf(SLAVE_PC, "\n\rResetting...");
reset_cpu();
break;
}
}
}
setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
} |
Code: | #include <16F887.h>
#device adc=16
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES PUT //Power Up Timer
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#use delay(clock=20000000)
#use FIXED_IO( A_outputs=PIN_A7,PIN_A6,PIN_A5,PIN_A4,PIN_A3,PIN_A2,PIN_A1,PIN_A0 )
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=SLAVE_PC) |
can any help me to resolve this problem? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Apr 15, 2013 3:30 pm |
|
|
It compiles with no errors for me. I made it all be one file.
I didn't include the bottom code as v2.h, I just put it at the top of
the main code. I used compiler vs. 4.140.
From the .LST file:
Quote: |
CCS PCM C Compiler, Version 4.140, 15-Apr-13 14:28
Filename: C:\Program Files\PICC\Projects\PCM_Test\PCM_Test.lst
ROM used: 1395 words (17%)
Largest free fragment is 2048
RAM used: 92 (25%) at main() level
110 (30%) worst case
Stack: 7 worst case (4 in main + 3 for interrupts) |
From the MPLAB Output window (Build tab):
Quote: |
Executing: "C:\Program files\Picc\CCSC.exe" +FM "C:\Program Files\PICC\Projects\PCM_Test\PCM_Test.c" +DF +LY -T -A +M -Z +Y=9 +EA -EW
--- Info 300 "C:\Program Files\PICC\drivers\modbus_phy_layer_rtu.c" Line 25(1,1): More info: Timer 1 tick time is 102.40 us
Memory usage: ROM=17% RAM=25% - 30%
0 Errors, 0 Warnings.
Build Successful.
Loaded C:\Program Files\PICC\Projects\PCM_Test\PCM_Test.cof.
BUILD SUCCEEDED: Mon Apr 15 14:28:04 2013 |
|
|
|
josb86
Joined: 15 Apr 2013 Posts: 8
|
|
Posted: Tue Apr 16, 2013 8:12 am |
|
|
I tried reinstall the program and before it after compile ok |
|
|
|
|
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
|