# How do I go about configuring SDLC on Serial Port F of a Rabbit 6000?

**URL:** <https://forums.digi.com/t/how-do-i-go-about-configuring-sdlc-on-serial-port-f-of-a-rabbit-6000/11868>\
**Category:** Rabbit Software\
**Tags:** hdlc, sdlc\
**Created:** [August 20, 2013, 12:50pm UTC](https://forums.digi.com/t/how-do-i-go-about-configuring-sdlc-on-serial-port-f-of-a-rabbit-6000/11868 "2013-08-20T12:50:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ndjankov](https://avatars.discourse-cdn.com/v4/letter/n/e56c9b/32.png) [@ndjankov](https://forums.digi.com/u/ndjankov)\
**Post date:** [August 20, 2013, 12:50pm UTC](https://forums.digi.com/t/how-do-i-go-about-configuring-sdlc-on-serial-port-f-of-a-rabbit-6000/11868/1 "2013-08-20T12:50:16Z")

</div>

Greetings,

I am in the process of connecting my RCM6700 dev kit to an full-duplex SDLC device. I have figured out how to make the electrical connections, but I am not quite sure how to configure the rabbit core to use SDLC on Serial Port F.

I see that there is an HDLC library that comes with Dynamic C, but I could not find any examples that use it, nor am I sure how to use this library to talk SDLC.

Any additional information/documentation would be greatly appreciated.

Thanks,

Nick

---

<div class="post-metadata">

**Author:** ![ndjankov](https://avatars.discourse-cdn.com/v4/letter/n/e56c9b/32.png) [@ndjankov](https://forums.digi.com/u/ndjankov)\
**Post date:** [September 3, 2013, 3:47pm UTC](https://forums.digi.com/t/how-do-i-go-about-configuring-sdlc-on-serial-port-f-of-a-rabbit-6000/11868/2 "2013-09-03T15:47:08Z")

</div>

Well, I found that HDLC is compatible with SDLC for my purposes, so the HDLC library would be sufficient if I could get it to work.

I did find an old HDLC test example for 3000 series chips (see below), but the library should make the Rabbit 6000 transparent, assuming that I could get the port configured correctly.

I made some changes to this test program to have Serial Port F use pins PC0 through PC3, but these do not seem to work (see below).

I was able to verify that the pins work in a RS232 loopback test; however, when I load the HDLS loopback program, there are no signals on these pins.

I still must be missing something to properly configure HDLC on Serial Port F to use Port C … any suggestions?

Sample Source Code:

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
hdlc\_test.c  
Z-World, 2002

```
This program is used with Rabbit 3000 based controllers.  

Description  
===========  
This program demonstrates a simple loopback test on  
either serial port E or serial port F in HDLC mode.  

Instructions  
============  
1. Simply connect PG6 (TXE) to PG7 (RXE) to use serial port E,  
   or connect PG2 (TXF) to PG3 (RXF) to use serial port F.  
2. Compile and run this program.  
3. Packets are sent out and received on the same port.  

```

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/  
#class auto

#use hdlc\_packet.lib

// uncomment only one of the following two macro definitions  
//#define USE\_HDLC\_SERIALPORTE  
#define USE\_HDLC\_SERIALPORTF

#ifdef USE\_HDLC\_SERIALPORTE  
#ifdef USE\_HDLC\_SERIALPORTF  
#warnt “Not set up to use both serial ports E and F, using only serial port E.”  
#endif  
#define HDLCopenX HDLCopenE  
#define HDLCsendingX HDLCsendingE  
#define HDLCsendX HDLCsendE  
#define HDLCerrorX HDLCerrorE  
#define HDLCpeekX HDLCpeekE  
#define HDLCdropX HDLCdropE  
#else  
#ifdef USE\_HDLC\_SERIALPORTF  
#define HDLC\_F\_USEPORT C //NDJ: added this line (as per HDLC\_PACKET.LIB, loopback wired PC0 to PC1 and PC2 to)  
#define SERF\_TXPORT PCDR //NDJ: added this line (as per page 34 of MiniCore RCM5700/RCM6700 User’s Manual)  
#define SERF\_RXPORT PCDR //NDJ: added this line (as per page 34 of MiniCore RCM5700/RCM6700 User’s Manual)  
#define HDLCopenX HDLCopenF  
#define HDLCsendingX HDLCsendingF  
#define HDLCsendX HDLCsendF  
#define HDLCerrorX HDLCerrorF  
#define HDLCpeekX HDLCpeekF  
#define HDLCdropX HDLCdropF  
#else  
#warnt “Must use either serial port E or serial port F.”  
#endif  
#endif

#define BUFFER\_COUNT 4  
#define BUFFER\_SIZE 100  
#define BAUD\_RATE 153600L //NDJ: changed Baud rate

void main()  
{  
char tx\_packet[100];  
char rx\_packet[100];  
int packet\_size;  
unsigned long xbuffers;  
char errors;  
int counter;  
unsigned long t;  
int temp\_flags;  
int temp\_length;  
int i;  
int recv\_count;  
unsigned long peekaddr;  
int peeklen;

```
xbuffers = xalloc(BUFFER_COUNT * (BUFFER_SIZE + 4));   
HDLCopenX( BAUD_RATE,   
                HDLC_NRZ,   
                xbuffers,   
                BUFFER_COUNT,   
                BUFFER_SIZE );   
counter = 1;   
recv_count = 0;   

while(1)   
{   
    if(HDLCsendingX() == 0)   
    {   
        for(i = 0;i &lt; 10;i++)   
        {   
            tx_packet[i] = '0' + (counter % 10);   
        }   
        tx_packet[10] = 0;   

        strcpy(tx_packet, "CatMouse987654321");   
        printf("Sending packet '%s', length:%d

```

", tx\_packet, strlen(tx\_packet));

```
        if(HDLCsendX(tx_packet, strlen(tx_packet)) == 1)   
        {   
            counter++;   
        }   
        else   
        {   
            printf("Packet not sent

```

");  
}  
}

```
    errors = HDLCerrorX();   
    if(errors)   
    {   
        printf("ERROR 0x%x

```

", errors);  
}

```
    //use the more efficient peek method   
    if(HDLCpeekX(&amp;peekaddr, &amp;peeklen))   
    {   
        xmem2root(rx_packet, peekaddr, peeklen);   
        packet_size = peeklen;   
        HDLCdropX();   
    }   
    else   
    {   
        packet_size = 0;   
    }   

    if(packet_size &gt; 0)   
    {   
        rx_packet[packet_size] = 0;   
        printf("Got packet(%d): '%s'

```

", packet\_size, rx\_packet);  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![ndjankov](https://avatars.discourse-cdn.com/v4/letter/n/e56c9b/32.png) [@ndjankov](https://forums.digi.com/u/ndjankov)\
**Post date:** [October 3, 2013, 8:42am UTC](https://forums.digi.com/t/how-do-i-go-about-configuring-sdlc-on-serial-port-f-of-a-rabbit-6000/11868/3 "2013-10-03T08:42:38Z")

</div>

I finally back to working on this. It turns out I just needed to configure Parallel Port C for the alternative function by adding “WrPortI(PCALR, NULL, 0xFF);” at the beginning of the loopback program.

---

<div class="post-metadata">

**Author:** ![ndjankov](https://avatars.discourse-cdn.com/v4/letter/n/e56c9b/32.png) [@ndjankov](https://forums.digi.com/u/ndjankov)\
**Post date:** [October 7, 2013, 12:16pm UTC](https://forums.digi.com/t/how-do-i-go-about-configuring-sdlc-on-serial-port-f-of-a-rabbit-6000/11868/4 "2013-10-07T12:16:20Z")

</div>

Actually, that didn’t quite work out, but it was on the right track. There were a few more port configuration that need to be set to get things working. After calling HDLCopenX(), you need to configure the following registers:

PCALR = 0xFF (set PC0-PC4 to HDLC alternative mode)  
PCAHR = 0x00 (leave in default mode)  
PCFR = 0x0F (enable alternative functionality)  
PCDDR = 0x05 (set in/out directions)  
SFCR = 0x0D (choose parallel port C pins for serial port F)  
SFER = 0x00 (I used default HDLC configurations)

---

<div class="post-metadata">

**Author:** ![kobong](https://avatars.discourse-cdn.com/v4/letter/k/9d8465/32.png) [@kobong](https://forums.digi.com/u/kobong)\
**Post date:** [April 8, 2014, 12:31am UTC](https://forums.digi.com/t/how-do-i-go-about-configuring-sdlc-on-serial-port-f-of-a-rabbit-6000/11868/5 "2014-04-08T00:31:44Z")

</div>

RCM6700 core module & interface board …  
Serial Port F, HDLC mode test …  
Above example… After calling HDLCopenX() …

WrPortI(PEALR, NULL, 0x7F); // set PE0-PE2 to HDLC alternative mode \*/  
WrPortI(PEAHR, NULL, 0x00); // leave in default mode  
WrPortI(PEFR , NULL, 0x07); // enable alternative functionality  
WrPortI(PEDDR, NULL, 0x05); // set in/out directions  
WrPortI(SFCR, NULL, 0x6D); // choose parallel port E pins for serial port F  
WrPortI(SFER, NULL, 0x00); //I used default HDLC configurations

thanks…
