diff --git a/board/redbee-dev.h b/board/redbee-dev.h index afcdc710f..d7401a60d 100644 --- a/board/redbee-dev.h +++ b/board/redbee-dev.h @@ -1,10 +1,21 @@ #ifndef BOARD_REDBEE_DEV_H #define BOARD_REDBEE_DEV_H -#include - #define LED_RED (1 << 23) #define LED_GREEN (1 << 24) #define LED_BLUE (1 << 25) +/* XTAL TUNE parameters */ +/* see http://devl.org/pipermail/mc1322x/2009-December/000162.html */ +/* for details about how to make this measurment */ + +/* Coarse tune: add 4pf */ +#define CTUNE_4PF 1 +/* Coarse tune: add 0-15 pf */ +#define CTUNE 3 +/* Fine tune: add FTUNE * 156fF (FTUNE is 4bits) */ +#define FTUNE 6 + +#include + #endif diff --git a/board/redbee-r1.h b/board/redbee-r1.h index 79bde2d4e..7737dc33b 100644 --- a/board/redbee-r1.h +++ b/board/redbee-r1.h @@ -1,10 +1,21 @@ #ifndef BOARD_REDBEE_R1_H #define BOARD_REDBEE_R1_H -#include - #define LED_RED (1 << 8) #define LED_GREEN (1 << 9) #define LED_BLUE (1 << 10) +/* XTAL TUNE parameters */ +/* see http://devl.org/pipermail/mc1322x/2009-December/000162.html */ +/* for details about how to make this measurment */ + +/* Coarse tune: add 4pf */ +#define CTUNE_4PF 1 +/* Coarse tune: add 0-15 pf */ +#define CTUNE 3 +/* Fine tune: add FTUNE * 156fF (FTUNE is 4bits) */ +#define FTUNE 2 + +#include + #endif diff --git a/board/std_conf.h b/board/std_conf.h index e6376a7f9..2559a6063 100644 --- a/board/std_conf.h +++ b/board/std_conf.h @@ -7,4 +7,24 @@ #define vreg_init() default_vreg_init() #endif +/* XTAL TUNE parameters */ +/* recommended defaults from the datasheet */ + +/* Coarse tune: add 4pf */ +#ifndef CTUNE_4PF +#define CTUNE_4PF 1 +#endif +/* Coarse tune: add 0-7 pf */ +#ifndef CTUNE +#define CTUNE 5 +#endif +/* Fine tune: add FTUNE * 156fF (FTUNE is 4bits) */ +#ifndef FTUNE +#define FTUNE 16 +#endif +/* datasheet recommends taht you don't change this */ +#ifndef IBIAS +#define IBIAS 0x1F +#endif + #endif diff --git a/libmc1322x/include/crm.h b/libmc1322x/include/crm.h index 068b335d2..274ae0021 100644 --- a/libmc1322x/include/crm.h +++ b/libmc1322x/include/crm.h @@ -97,4 +97,7 @@ #define SLEEP_RAM_64K sleep_ram_retain(2) #define SLEEP_RAM_96K sleep_ram_retain(3) +#define pack_XTAL_CNTL(ctune4pf, ctune, ftune, ibias) \ + (*CRM_XTAL_CNTL = ((ctune4pf << 25) | (ctune << 21) | ( ftune << 16) | (ibias << 8) | 0x52)) + #endif diff --git a/tests/rftest-rx.c b/tests/rftest-rx.c index bb4c53df7..b0af7a7bc 100644 --- a/tests/rftest-rx.c +++ b/tests/rftest-rx.c @@ -52,6 +52,9 @@ void main(void) { vreg_init(); init_phy(); + /* trim the reference osc. to 24MHz */ + pack_XTAL_CNTL(CTUNE_4PF, CTUNE, FTUNE, IBIAS); + set_power(0x0f); /* 0dbm */ set_channel(0); /* channel 11 */ diff --git a/tests/rftest-tx.c b/tests/rftest-tx.c index 117c6ff5e..dad7c3c09 100644 --- a/tests/rftest-tx.c +++ b/tests/rftest-tx.c @@ -70,6 +70,9 @@ void main(void) { flyback_init(); init_phy(); + /* trim the reference osc. to 24MHz */ + pack_XTAL_CNTL(CTUNE_4PF, CTUNE, FTUNE, IBIAS); + set_power(0x0f); /* 0dbm */ set_channel(0); /* channel 11 */