cancel
Showing results for 
Search instead for 
Did you mean: 

Help: HDLC with FM0/MANCH encoding

huashilong
Associate II
Posted on September 17, 2006 at 01:50

Help: HDLC with FM0/MANCH encoding

1 REPLY 1
huashilong
Associate II
Posted on September 17, 2006 at 01:50

Hi All,

My code work well with NRZ/NRZI encoding, but can't work with FM0/MANCH encoding. Can anyone help me? thank you very much!

here is the code :

//=============================================================================

#define CODE_NRZ 0

#define CODE_NRZI 1

#define CODE_FM0 2

#define CODE_MANCH 3

void HDLC_Init(unsigned char tx_code,unsigned int tx_bps,unsigned char rx_code,unsigned int rx_bps)

{

HDLC->GA1 = 0;

HDLC->GA0 = 0;

HDLC->GAM1 = 0;

HDLC->GAM0 = 0;

HDLC->PRES = 0;

HDLC->POSS = 0;

HDLC->TCTL = 0;

HDLC->RCTL = 0;

HDLC->BRR = 0;

HDLC->PRSR = 0;

HDLC->TFBCR = 0;

HDLC->RFBCR = 0;

HDLC->PCR = 0;

HDLC->ISR = 0;

HDLC->IMR = 0;

HDLC->PARH = 0;

HDLC->PAMH = 0;

HDLC->PARL = 0x00AA;

HDLC->PAML = 0x00FF;

GPIO_Config (GPIO1, 0x2000, GPIO_IN_TRI_CMOS);

GPIO_Config (GPIO1, 0x4000, GPIO_IN_TRI_CMOS);

GPIO_Config (GPIO1, 0x8000, GPIO_AF_PP);

if((tx_code==CODE_NRZ)||(tx_code==CODE_NRZI))

{

HDLC->TCTL = (((unsigned short)1)<

HDLC->BRR = ((RCCU_FrequencyValue(RCCU_FCLK)/tx_bps-1) & 0x0FFF);

}

else //((tx_code==CODE_FM0)||(tx_code==CODE_MANCH)

{

HDLC->TCTL = (((unsigned short)1)<

HDLC->BRR = ((RCCU_FrequencyValue(RCCU_FCLK)/tx_bps/2-1) & 0x0FFF);

}

if((rx_code==CODE_NRZ)||(rx_code==CODE_NRZI))

{

HDLC->RCTL = (((unsigned short)1)<

HDLC->PRSR = ((RCCU_FrequencyValue(RCCU_FCLK)/rx_bps-1) & 0x00FF);

}

else //((tx_code==CODE_FM0)||(tx_code==CODE_MANCH))

{

HDLC->RCTL = (((unsigned short)1)<

HDLC->PRSR = ((RCCU_FrequencyValue(RCCU_FCLK)/rx_bps/2-1) & 0x00FF);

}

}