Problems with PortF RS-485 in a RCM5700 Deluxe Development Kit

Can anyone tell me why this example does not work?

The version with cof_serFgetc() and cof_serFputc() functions work fine but the version with cof_serFread() and cof_serFwrite() not. This version give me the following warnings:

Line 5399: WARNING RS232.LIB: Wrong type for parameter 1.
Line 5399: WARNING RS232.LIB: Conversion to incompatible pointer type.

And the Run Time Error: Invalid cofunction instance. Address c0:0008 just when a character arrive and the program execute de cof_serFwrite().

Code here:

cofEchoChar.c

#use miRCM57xx.lib

#define FINBUFSIZE 15
#define FOUTBUFSIZE 15
#define SERF_RXPORT PDDR
#define SERF_TXPORT PDDR
#define _485BAUD 19200L

/------------------------------------------------------------------
Enables the RS485 transmitter.
-------------------------------------------------------------------
/
nodebug
root void ser485Tx( void )
{
#asm
push ip ;save off IP state
ipset 1 ;set interrupt priority to level 1
ld a,(PDDRShadow) ;get copy of shadow reg
or 0x02 ;set bit 1 high (PD1)
ld (PDDRShadow),a ;update shadow reg
ioi ld (PDDR),a ;set PF5 high
pop ip ;restore IP to the previous state
ret
#endasm
}

/------------------------------------------------------------------
Disables the RS485 transmitter.
This puts the device in listen mode which allows to receive data
from the RS485 interface.
--------------------------------------------------------------------
/
nodebug
root void ser485Rx( void )
{
#asm
push ip ;save off IP state
ipset 1 ;set interrupt priority to level 1
ld a,(PDDRShadow) ;get copy of shadow reg
and 0xFD ;clear bit 1 (PD1)
ld (PDDRShadow),a ;update shadow reg
ioi ld (PDDR),a ;set PF5 low
pop ip ;restore IP to the previous state
ret
#endasm
}

main()
{
char car;

brdInit(); //initialize board for this demo
ser485Rx(); //Disable transmitter, initially put in receive mode

// Open Serial Port F
serFopen (_485BAUD);
serFdatabits (PARAM_8BIT);
serFflowcontrolOff ();
serFparity (PARAM_NOPARITY);
serFrdFlush();
serFwrFlush();

loopinit ();
for (;:wink:
{
loophead ();
costate
{
// wfd car = cof_serFgetc (); // yields until successfully getting a character
wfd cof_serFread (&car, 1, 1000UL);
printf ("%c
", car);
ser485Tx(); // Disable transmitter, initially put in receive mode
// wfd cof_serFputc (car); // then yields here until c successfully put
wfd cof_serFwrite (&car, 1);
// Allow transmission to complete before to close:
waitfor (serFwrUsed () == 0);
waitfor (!BitRdPortI (SFSR,2) && !BitRdPortI (SFSR,3));
serFrdFlush(); // Eliminar el rebote.
ser485Rx(); // Disable transmitter, initially put in receive mode
}
}
}

miRCM57xx.lib

/*** BeginHeader */
#ifndef __RCM57XX_LIB
#define __RCM57XX_LIB

#if !RCM5700_SERIES
#fatal “RCM57XX.LIB only supports RCM57XX series boards.”
#endif

/*** EndHeader */

/* START LIBRARY DESCRIPTION *********************************************
RCM57XX.LIB

DESCRIPTION: This is a sample library only.

           Use with RCM57XX series controllers and interface boards.
           Add or modify functions to suit your applications.

           RCM5700 Standard Setup:
           50MHz R5000, 1M Flash, 128k internal SRAM, 100BASE-T Ethernet

           Modificado para Prue\P01

END DESCRIPTION **********************************************************/

/*** BeginHeader /
#define DEVELOPMENT_BOARD // Indicate development board LIB being used
/
** EndHeader */

/*** BeginHeader __brdinitflag /
extern int __brdinitflag;
/
** EndHeader */
int __brdinitflag; //Board init function flag

/*** BeginHeader brdInit /
void brdInit(void);
/
** EndHeader */

/* START FUNCTION DESCRIPTION ********************************************
brdInit

SYNTAX: void brdInit (void);

DESCRIPTION: This function initializes parallel ports A through E for
RCM57XX series core modules running on an RCM57XX series
interface board.

           Default I/O port configuration:
           -------------------------------
           The brdInit function sets up a default I/O configuration
           for the RCM5700 and the standard interface board.

           Note:
           -----
           This function is intended for demonstration purposes only
           and can be modified for your applications.

PARAMETER: None

RETURN VALUE: None


General information and I/O initialization when using an RCM57XX series
core module on an RCM57XX interface board.

Summary of initialization

  1. I/O port pins are configured for interface board operation.
  2. Unused configurable I/O are set as outputs.
  3. LEDs are off.
  4. Slave port disabled.

Pins B1, C6-C7, D7 and E4 are separately configured by the BIOS and
associated libraries.

Note that parallel port H is not connected to the I/O edge connector,
so is not available for use as a general purpose I/O port.

Pin Port Function I/O I/O State
=== ==== =============================== ====== ======================
35 PA0 Not used Output High
36 PA1 Not used Output High
37 PA2 Not used Output High
38 PA3 Not used Output High
39 PA4 DS1 Output High LED-OFF
40 PA5 DS2 Output High LED-OFF
41 PA6 DS3 Output High LED-OFF
42 PA7 DS4 Output High LED-OFF

27 PB0 RCM5700/10: Not used Output High
RCM5750/60: CLKB - Serial flash Output Setup by sflash driver
46 PB1 CLKA - Programming port Output High when not driven
29 PB2 Not used Output High
30 PB3 Not used Output High
31 PB4 S1 Input Pulled-up on interfaz
32 PB5 S2 Input Pulled-up on interfaz
33 PB6 S3 Input Pulled-up on interfaz
34 PB7 S4 Input Pulled-up on interfaz

21 PC0 Not used Output High
22 PC1 Not used Output High
23 PC2 Not used Output High
24 PC3 Not used Output High
25 PC4 Not used Output High
26 PC5 Not used Output High
48 PC6 TXA - Programming port Output Driven
50 PC7 RXA - Programming port Input Pulled-up on core

17 PD0 LED DS1 Output High (off)
18 PD1 RS-485 DENA Output Low
19 PD2 RS-485 TxF Output High
20 PD3 RS-485 RxF Input
NC PD4 RCM5700/10: Not used Output High
RCM5750/60: TXB - Serial flash Output Setup by sflash driver
NC PD5 RCM5700/10: Not used Output High
RCM5750/60: RXB - Serial flash Input Setup by sflash driver
NC PD6 RCM5700/10: Not used Output High
RCM5750/60: /CS - Serial flash Output Setup by sflash driver
NC PD7 10/100 Output Driven

09 PE0 Not used Output High
10 PE1 Not used Output High
11 PE2 Not used Output High
12 PE3 Not used Output High
NC PE4 RESET_PHY Output Low when not driven
13 PE5 Not used Output High
14 PE6 Not used Output High
15 PE7 Not used Output High

NC PH0 Not available Output High
NC PH1 Not available Output High
NC PH2 Not available Output High
NC PH3 Not available Output High
NC PH4 Not available Output High
NC PH5 Not available Output High
NC PH6 Not available Output High
NC PH7 Not available Output High
END DESCRIPTION *********************************************************/

nodebug
void brdInit(void)
{
#GLOBAL_INIT {__brdinitflag = FALSE;}

/////////////////////////////////////////////////////////////////////////
// Configure Port A
/////////////////////////////////////////////////////////////////////////
WrPortI(PADR, &PADRShadow, 0xFF); // set to output all high
WrPortI(SPCR, &SPCRShadow, 0x84); // sets pins to all outputs

/////////////////////////////////////////////////////////////////////////
// Configure Port B – Leave PB1 untouched (used for other purposes)
// RCM5750/60 only: PB0 set up by serial flash driver
/////////////////////////////////////////////////////////////////////////
WrPortI(PBDR, &PBDRShadow, RdPortI(PBDR) | 0x0D); // set outputs to high
WrPortI(PBDDR, &PBDDRShadow, RdPortI(PBDDR) & 0x0F | 0x0D); // set pins to output

/////////////////////////////////////////////////////////////////////////
// Configure Port C – Leave PC6 and PC7 untouched (used for other purposes)
/////////////////////////////////////////////////////////////////////////
WrPortI(PCFR, &PCFRShadow, RdPortI(PCFR) & 0xC0); // no special functions
// except PC6 and PC7
WrPortI(PCDCR, &PCDCRShadow, RdPortI(PCDCR) & 0xC0); // clear bits to drive
// high and low
WrPortI(PCDR, &PCDRShadow, RdPortI(PCDR) | 0x3F); // set outputs high
WrPortI(PCDDR, &PCDDRShadow, RdPortI(PCDDR) | 0x3F); // set inputs and
// outputs

/////////////////////////////////////////////////////////////////////////
// Configure Port D – Leave PD7 untouched (used for other purposes)
// RCM5750/60 only: PD4,5,6 set up by serial flash driver
/////////////////////////////////////////////////////////////////////////
WrPortI(SFCR,&SFCRShadow,0x11); //set port D for data…use Int Priority 1

WrPortI(PDCR, &PDCRShadow, RdPortI(PDCR) & 0x80); // clear bits to pclk/2
WrPortI(PDDCR, &PDDCRShadow, RdPortI(PDDCR) & 0x80); // clear bits to drive
// high and low
WrPortI(PDDR, &PDDRShadow, RdPortI(PDDR) & 0xFD | 0x75); // DataRegister
WrPortI(PDDDR, &PDDDRShadow, RdPortI(PDDDR) & 0xF7 | 0x77); // DataDirectionRegister

WrPortI(PDFR,&PDFRShadow, 0x04); // set PD2 as TxF alt output
WrPortI(PDALR,&PDALRShadow, 0x30); // set PD2 as TxF alt output

/////////////////////////////////////////////////////////////////////////
// Configure Port E – Leave PE4 untouched (used for other purposes)
/////////////////////////////////////////////////////////////////////////
WrPortI(PECR, &PECRShadow, RdPortI(PECR) & 0x10); // clear bits to pclk/2
WrPortI(PEFR, &PEFRShadow, RdPortI(PEFR) & 0x10); // no special function
WrPortI(PEDCR, &PEDCRShadow, RdPortI(PEDCR) & 0x10); // clear bits to drive
// high and low
WrPortI(PEDR, &PEDRShadow, RdPortI(PEDR) | 0xEF); // set outputs high
WrPortI(PEDDR, &PEDDRShadow, RdPortI(PEDDR) | 0xEF); // set bits to output

/////////////////////////////////////////////////////////////////////////
// Configure Port H
/////////////////////////////////////////////////////////////////////////
WrPortI(PHFR, &PHFRShadow, 0x00); // no special functions
WrPortI(PHDCR, &PHDCRShadow, 0x00); // clear all bits to drive high and low
WrPortI(PHDR, &PHDRShadow, 0xFF); // set all bits high
WrPortI(PHDDR, &PHDDRShadow, 0xFF); // set all bits to output

__brdinitflag = TRUE;
}

/*** BeginHeader /
#endif
/
** EndHeader */

Here the response from Rabbit support:

Using DC 10.62 or DC 10.64 to run the Samples\SERIAL\cof_echoblk.c standard sample program, when single stepping through the generated code (either make costate.lib and cofunc.lib code debuggable, or step via the disassembly window), I see the reported run time error occur in the same place each time. The run time exception occurs in the second costate, when the IDLE_TMOUT has occurred and the wfd cof_serBputs() is executed. DC 10.60 appears to work OK.

A work around is to substitute DC 10.60’s Lib\Rabbit4000\RS232.LIB and Lib\Rabbit4000\CBUF.LIB into DC 10.64 (or DC 10.62). After this substition in DC 10.64 a warning is produced, e.g.:

line 2540 : WARNING RS232.LIB : Type mismatch: incompatible types void() and int( *)() used in expression.

This warning can be safely ignored, as it occurs when void * spd_dummyfunc is assigned to int * serDdata.xCheckCTS, where the dummy function is never actually called because an appropriate assignment from int * spd_checkcts_fc is made when HW flow control is enabled.

Please download Dynamic C 10.6 and let me know if this helps.
Best regards,
M. Kronenberg
Technical Support Engineer - Rabbit Brand Digi International (530)-757-8400 Email:support@rabbit.com www.digi.com www.rabbit.com

If you require more assistance with this issue, please REPLY to this email and do not change the subject.
If you have a new issue please change the subject.