How to change the N76E003 HIRC frequency for more accurate UART transmission?

Post Reply
Posts: 116
Joined: 20 Mar 2017, 10:52

28 Mar 2017, 10:39

The N76E003 HIRC frequency is 16 MHz and the deviation is less than 1% at room temperature. When using the baud rate up to 38400 for UArT transmission, 16 MHz cannot be divided by 38400 Hz, such that baud rate deviation is too large and the transmission cannot be stabilized.
At this time, user can change the HIRC frequency to 16.588 MHz to produce an accurate baud rate.

The steps of changing the HIRC frequency are as follows:
Trim value = RCTRIM0(HIRCTRIM[8:1]) + RCTRIM1(HIRCTRIM[0])
Adjust the HIRC frequency to 16.6 MHz;
Write the calculated value back to RCTRIM0 and RCTRIM1, and the HIRC change will take effect immediately after writing;
The HIRC will revert to 16 MHz after each power-up, and the user needs to change the HIRC by writing the SFR.
Recalculate the baud rate based on 16.588 MHz and set the baud rate generated by the timer to meet the standard baud rate.

Example samples:
sfr RCTRIM0 = 0x84;
sfr RCTRIM1 = 0x85;
bit BIT_TMP;

#define set_IAPEN BIT_TMP = EA; EA=0; TA=0xAA; TA=0x55; CHPCON |= SET_BIT0; EA= BIT_TMP
#define set_IAPGO BIT_TMP = EA; EA = 0; TA = 0xAA; TA = 0x55; IAPTRG |= SET_BIT0; EA = BIT_TMP
#define clr_IAPEN BIT_TMP = EA; EA = 0; TA = 0xAA; TA = 0x55; CHPCON &= ~SET_BIT0; EA=BIT_TMP

unsigned char hircmap0,hircmap1;
unsigned int trimvalue16bit;

IAPAL = 0x30;
IAPAH = 0x00;
hircmap0 = IAPFD;
IAPAL = 0x31;
IAPAH = 0x00;
hircmap1 = IAPFD;
trimvalue16bit = ((hircmap0<<1)+(hircmap1&0x01));
trimvalue16bit = trimvalue16bit - 15;
hircmap1 = trimvalue16bit&0x01;
hircmap0 = trimvalue16bit>>1;
RCTRIM0 = hircmap0;
RCTRIM1 = hircmap1;

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 0 guests