Silicon Laboratories Si4010 Software Programming Manual
Silicon Laboratories Si4010 Software Programming Manual

Silicon Laboratories Si4010 Software Programming Manual

Hide thumbs Also See for Si4010:

Advertisement

Si4010 S
O FT W A R E

1. Purpose

This document defines the application programming interface (API) for the Si4010 firmware. It is intended to serve
as a guide for application development.
The document is related to the device revision 0x02 as returned by bSys_GetRevId() function and Trim version
0x09 as returned by the Device Information in the NVM Programming Utility. It describes files needed to build
customer application and the details of the implemented API functions in ROM. There are also additional API
functions not present in ROM, provided in the form of a linkable library for the Keil toolchain. For a description of
this additional library, see "AN526: Si4010 API Additional Library Description".

2. Known Issues

These are known issues related to the current version of the Si4010 device hardware revision 0x02 as returned by
bSys_GetRevId() function and Trim version 0x09 as returned by the Device Information in the NVM Programming
Utility.
There is an issue related to the LED driver, which demonstrates itself only under the following circumstances
when all three conditions are satisfied:
The device programming level is Factory or User. For those levels the C2 debugging interface is enabled after the boot by

a boot routine.
The device has been disconnected from the Silicon Labs IDE. The "disconnected" means in a software sense, not

physically, using the Connect/Disconnect buttons on IDE. Or, the device is running the User code automatically after the
boot without ever being connected to the IDE.
The device is running a code which turns the LED on and off.

If all the conditions are satisfied then after the first LED blink when the LED is turned off the GPIO4 stops working
and is no longer visible to the application.
If the device programming level is Run or the C2 debugging interface is internally disabled there is no issue. The
LED can be turned on and off without affecting the device GPIO4 functionality.
The issue can be summarized as follows: Whenever the C2 debugging interface is enabled, the device is not
connected to IDE, and the LED is turned on and off, then the GPIO4 will stop functioning. Since in Run mode the
C2 is disabled after the boot process finishes, the GPIO4 is not affected.
Therefore, this issue only effects software development process and inconveniences the developer. After the
application is finalized and the chip is programmed as Run there is no issue. See suggested solution scenarios and
workarounds in the section related to debugging with LED.
Rev. 1.0 2/12
P
ROGRAMMING
Copyright © 2012 by Silicon Laboratories
AN370
G
U ID E
AN370

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the Si4010 and is the answer not in the manual?

Questions and answers

Summary of Contents for Silicon Laboratories Si4010

  • Page 1: Purpose

    “AN526: Si4010 API Additional Library Description”. 2. Known Issues These are known issues related to the current version of the Si4010 device hardware revision 0x02 as returned by bSys_GetRevId() function and Trim version 0x09 as returned by the Device Information in the NVM Programming Utility.
  • Page 2 AN370 Rev. 1.0...
  • Page 3: Table Of Contents

    AN370 ABLE O F ONTENTS Section Page 1. Purpose ..............1 2.
  • Page 4: Memory Regions

    MTP API Module. User should use the MTP API for read access as well. HVRAM HVRAM in the Si4010 consists of 64 bits (8 bytes) of battery backed RAM. As long as the power is connected to the chip, the HVRAM keeps its content. The content of the HVRAM is not affected by shutting down the chip by vSys_Shutdown() function.
  • Page 5: 8051 Internal Memory

    3.2. Memory Map After the chip boots, the memory on the Si4010 is mapped as shown in Figure 2. The 4.5 kB RAM section is accessible both as CODE and XDATA (MOVC and MOVX instructions). The XREG region is accessible only as XDATA (MOVX).
  • Page 6: Code/Xdata Ram Reserved Area

    IDE, for example) the value of the wBoot_DpramTrimBeg variable, which points to the first used address in the CODE/XDATA RAM. Any location at lower address then the one pointed to by the content of the wBoot_DpramTrimBeg variable is available for customer user. See the Boot section in the Si4010 data sheet. CODE/XDATA RAM 4.5KB...
  • Page 7 AN370 DATA/IDATA MCU Internal RAM 0x00 Reg RB0 Available (8B) 0x07 0x08 Registers RB1 .. RB3 Available (24B) 0x1F 0x20 Bit Addr DATA .. lower 128 Available RAM bytes, Direct (16B) 0x2F and Indirect 0x30 Addressing Reserved (16B) 0x3F 0x40 Available (64B) 0x7F...
  • Page 8: Building An Application

    AN370 4. Building an Application 4.1. Type Definitions The following table lists types that are defined or expected for use with the Si4010 API. The custom types are defined in the header file si4010_types.h Type Bit Width Type Definition Prefix...
  • Page 9 AN370 The module naming prefixes used are as follows: Module Prefix Module Name Button service routine DmdTs Temperature sensor and its demodulator Encoding of data for transmission Frequency counter FCast Frequency casting and fine tuning Hvram HVRAM MTP (EEPROM) memory MVdd Battery V measurement...
  • Page 10: Included Library Routines

    AN370 4.3. Included Library Routines Following is a list of all Keil library routines included in ROM. They are available for use by the application via the ROM symbol map file for Keil toolchain ( si4010_rom_keil.a51 The library routines cannot be used with other toolchains. If the user does not desire to link these library routines to the application (they take precedence over the actual library provided by the toolchain), then it is necessary to use si4010_rom_all.a51 instead of the Keil specific toolchain during the application building.
  • Page 11: Stack Size Requirements

    AN370 4.4. Stack Size Requirements Table 1 shows the additional stack requirements when the user code is calling an API function. The number of bytes in the table is in addition to the 2 bytes return address storage requirements for the return address to be stored on top of the stack when the function is called.
  • Page 12 AN370 Table 1. Additional Stack Requirements (Continued) bHvram_Read — vHvram_Write — lMtp_GetDecCount vMtp_SetDecCount vMtp_IncCount bMtp_Write pbMtp_Read vMtp_Strobe — iMVdd_Measure vNvm_SetAddr — wNvm_GetAddr — bNvm_CopyBlock — vNvm_McEnableRead vNvm_McDisableRead — vOds_Setup — vOds_Enable — vOds_WriteData — vPa_Setup vPa_Tune lSleepTim_GetCount vSleepTim_SetCount bSleepTim_CheckDutyCycle vSleepTim_AddTxTimeToCounter lSleepTim_GetOneHourValue —...
  • Page 13 AN370  Using only single interrupt priority level. The main application function can be interrupted by single ISR and any ISR will not get interrupted any further. It also assumes that the user is compiling the ISR routine with using directive.
  • Page 14: Hardware Thread Safety

    AN370 It is up to the user to adjust the recommended sizes above according to the application true needs. It is recommended to reserve the stack size by modifying the line defining the reserved size of the stack in startup.a51 (in the published examples the <example>_startup.a51 is distributed) to the proper value. By doing that the linker will notify the user when the reserved stack area is encroaching on other DATA/IDATA variables: ;--------------------------------------------------------------------------- CODE:...
  • Page 15: Function Calling Convention

    AN370 4.7. Function Calling Convention All input and output function variables are passed in registers. The function calling convention and parameter passing is a Keil convention. It is also used by Raisonance toolchain. Maximum 3 parameters can be passed to functions in registers.
  • Page 16: Files Needed For Building An Application

    API use. A commented section showing how to achieve that is included at the end of the file. If the Si4010 revision B silicon (Si4010-B1-GS or Si4010-B1-GT) is used, then the following file is also required: This file is needed only for Rev B. Keil library file containing fixed si4010_fix_rom_keil.lib...
  • Page 17 AN370 define all the SFR, XDATA mapped XREG registers, boot status variables, and interrupt priority numbers. Same items are defined in both the C and assembly headers, so only the C header is used to describe what is present there. The same applies to the assembly device header. For each of the fields in each of the SFR or XREG registers there is a register address defined.
  • Page 18: Compiling An Application

    To use the Si4010 API to build a user application in C, the user must do the following: 1. To be able to use the Silicon Laboratories IDE for debugging, the user must use the Keil BL51 linker or toolchain with the standard OMF-51 output file format.
  • Page 19 XDATA to use. The user has to look at the content of wBoot_DpramTrimBeg residing at the address 0x11F3. The variable content is directly accessible from the Silicon Labs IDE: View  Debug Windows  Si4010  System Vars It is critical that neither user CODE nor user XDATA will encroach on that space.
  • Page 20: User Application Required Interrupt Service Routines

    ISR priority level in the whole system then the RB1 can be used in the DMD ISR. Required DMD ISR. The ISR must call two DMD TS functions as shown. *------------------------------------------------------------------------------ INCLUDES: #include "si4010.h" #include "si4010_api_rom.h" *============================================================================== VISIBLE FUNCTIONS:...
  • Page 21 AN370 interrupt INTERRUPT_DMD using 2 /* Use RB2 for this ISR */ /*------------------------------------------------------------------------------ FUNCTION DESCRIPTION: This is the interrupt service routine for the DMD. It clears the DMD interrupt flag and calls the vDmdTs_IsrCall() which handles the interface to the demodulator and temperature sensor. Use RB1 ..
  • Page 22: Interrupt And System Impact Of Some Functions

    AN370 6. Interrupt and System Impact of Some Functions This section summarizes how functions impact interrupt enables, system clock settings, and key hardware blocks on the device. This information is provided such that the user will be able to consider the side effects of the API functions.
  • Page 23: Interrupt Enable Control

    AN370 6.2. Interrupt Enable Control Only the temperature sensor demodulator interrupt enabled EDMD bit and the global interrupt enable bit EA are manipulated by the API functions. One of the functions clears the EODS as well. There are functions manipulating the EA and EDMD flags directly and then functions manipulating them indirectly by calling the direct manipulator functions.
  • Page 24: System Clock Control

    AN370 6.3. System Clock Control The nominal, fastest, internal system clock frequency is 24 MHz. The user can set the lower frequency at any time by setting the SYSGEN.SYSGEN_DIV[2:0] three bit field. It is highly recommended that the application uses the vSys_SetClkSys() function to set that field.
  • Page 25: Transmission Chain Control

    AN370 6.4. Transmission Chain Control The transmission chain uses the LC oscillator, DIV divider, and the PA power amplifier. Those blocks are referred to as LC, DIV, and PA, respectively. They are controlled by the output serializer ODS when it is turned on by vOds_Enable(1) call.
  • Page 26 AN370 Table 4. Transmission Chain Control Functions vSys_ForceLc — — If the LC is on, the function returns immedi- ately, if not, then it forces LC on and waits 125 µs. iMVdd_Measure S, 1, R S, 1, R S, 1, R If the function is called with non-zero input argument biWait then it saves the current state, turns all one, then restores the state.
  • Page 27: Infinite Loops

    AN370 6.5. Infinite Loops Some of the API functions rely on the functioning hardware for functionality. They wait for some hardware action to finish. If the hardware is not configured correctly and the hardware block never gives the "finished" status to the API function, the system gets stuck in an infinite loop.
  • Page 28: Module Descriptions

    AN370 7. Module Descriptions 7.1. AES Module The Advanced Encryption Standard Module encrypts a 128 bit block using a 128 bit key. It is up to the user to declare a 16 byte DATA/IDATA plain or cipher text data array and a 16 byte DATA/IDATA key. Pointers to these arrays are passed into the AES functions and manipulated from within the module’s functions.
  • Page 29 AN370 7.1.1. AES Module Functions vAes_Cipher Description: Encrypts 128 bit data block with 128 bit key. Inputs: pbioState: (pointer to IDATA BYTE) Pointer to a byte which is the first byte in an array of 16 bytes. This array is the data to be encrypted. pbioRoundKey: (pointer to IDATA BYTE) Pointer to a byte which is the first byte in an array of 16 bytes.
  • Page 30 AN370 vAes_InvCipher Description: Decrypts 128 bit block with 128 bit key. Inputs: pbioState: (pointer to IDATA BYTE) Pointer to a byte which is the first byte in an array of 16 bytes. This array is the data to be decrypted. pbioRoundKey: (pointer to IDATA BYTE) Pointer to a byte which is the first byte in an array of 16 bytes.
  • Page 31: Button Service Module And Master Time

    AN370 7.2. Button Service Module and Master Time The Button Service Module implementing Button Service Routine (BSR) is responsible for debouncing (referred to as qualifying) button pushes/releases on the GPIO button inputs. Once a button push/release has been qualified, a record of it is stored in the Push Tracking Structure (PTS) FIFO.
  • Page 32 AN370 7.2.3. Error Cases It is possible to underflow the PTS. In this case, where the application pops too many elements out of the PTS, a button vector of zero and a timestamp of zero will be returned. As soon as another button push is qualified it will be pushed onto the PTS.
  • Page 33 AN370 7.2.5. Application Considerations It is the responsibility of the main application to remember the current state of the buttons being currently service. By other words, when the application uses wBsr_Pop() function it needs to remember the button vector. For example, application is waiting for a button press. If single button pressed and held, the button press item will be entered into the PTS FIFO.
  • Page 34 AN370 /* Disable the Matrix and Roff modes */ PORT_CTRL &= ~(M_PORT_MATRIX | M_PORT_ROFF | M_PORT_STROBE); PORT_CTRL |= M_PORT_STROBE; PORT_CTRL &= ~M_PORT_STROBE; /* Clear the master time */ vSys_SetMasterTime( 0UL ); /* Prepare the BSR for debouncing .. interested to monitor buttons * at GPIO1 and GPIO2 */ rBsrSetup.bButtonMask = (1 <<...
  • Page 35 AN370 wPtsButton = wBsr_Pop(); RTC ISR: *============================================================================== VISIBLE FUNCTIONS: void vIsr_Rtc void interrupt INTERRUPT_RTC using 1 /* Use RB1 for ISR */ /*------------------------------------------------------------------------------ FUNCTION DESCRIPTION: This is the interrupt service routine for RTC. *------------------------------------------------------------------------------ *------------------------------------------------------------------------------ VARIABLES: *------------------------------------------------------------------------------ /* Clear the RTL interrupt flag */ RTC_CTRL &= (~M_RTC_INT);...
  • Page 36 AN370 /* Sample the input buttons .. is uses the master time for timestamp */ vBsr_Service(); *------------------------------------------------------------------------------ Rev. 1.0...
  • Page 37 AN370 7.2.6. Button Service Module Structures tBsr_Setup Description: A pointer to a structure of this type is used as an input to the vBsr_Setup() function. The following table lists the members belonging to the tBsr_Setup structure. Name Type Description bButtonMask BYTE Mask that specifies which buttons to watch for pushes on:...
  • Page 38 AN370 7.2.7. Button Service Module Functions vBsr_Setup Description: Set up the button detection and debouncing for the chip. The function also initializes PTS pointers and attributes, calling the vBsr_InitPts() function internally. Inputs: priSetup: (pointer to tBsr_Setup instance) For contents of tBsr_Setup structure see table above.
  • Page 39 AN370 wBsr_GetCurrentButton Description: Returns information associated with the latest qualified button push/release. If no pushes have been qualified, it returns 0. The function does not remove the informa- tion from the PTS. It is the latest information which was pushed at the end of the FIFO if the FIFO was not full before the push.
  • Page 40 AN370 bBsr_GetPtsItemCnt Description: Returns the number of items in the PTS. Each item in the PTS FIFO rep- resents a button status change, push or release. Inputs: None Outputs: PTS item count: (BYTE) The number of elements in the PTS. Each element rep- resents a button push/release.
  • Page 41 AN370 vBsr_Service Description: This function performs the following tasks: 1. Every call of the function samples the input button states. 2. Debounces the button pushes/releases. 3. Writes valid button pushes into the PTS. It is up to the user application to call this function periodically whenever the input button states need to be sampled.
  • Page 42: Demodulator Temperature Sensor Module

    AN370 7.3. Demodulator Temperature Sensor Module This module is responsible for all interactions with the demodulator and temperature sensor. The Demodulator Interrupt Service Routine (DMD ISR) is required to be a part of the user application. In the application, once the demodulator and temperature sensor have been configured, the DMD ISR triggers each time a new sample is ready.
  • Page 43 AN370 Outputs: Temperature: (int) Signed output representing temperature in internal temperature units, representing temperature as 220 lsb/degC nominal scale with nominal zero point at 25degC. e.g., value 1100 corresponds to 30degC. This value is only for API internal use and is not calibrated for accurate ambient temperature measure- ment.
  • Page 44 AN370 vDmdTs_IsrCall Description: This function is to be called form the user application DMD ISR. It is up to the main application to define a DMD ISR routine. Then this function must be called from within that ISR. The function skips the number of temperate sensor demodulator samples specified in the biSampleSkipCount argument of the vDmdTs_Setup() function before it produces a new reading.
  • Page 45 AN370 vDmdTs_Enable Description: Controls the enabling and disabling of the temperature sensor digital demod- ulator (DMD) and the temperature sensor analog block (TS). Inputs: biDmdTsSetEnable: (BYTE) Bit 6 enables the digital demodulator (DMD) when set. Bit 7 enables the temperature sensor (TS) analog hardware when set. All other bits are unused.
  • Page 46 AN370 It is important to note that vDmdTs_RunForTemp() forces the DMD interrupt EDMD flag and the global interrupt enable EA flag to be enabled: EDMD = 1; EA = 1; Inputs: biSampleSkipCount: (BYTE) Parameter passed to the vDmdTs_Setup() function. It represents the number of output samples to skip before collecting values in the function vDmdTs_IsrCall().
  • Page 47 AN370 If the user wants to disable the temperature sensor to save power and then restart it later, it is more convenient to disable it and then reconfigure it again from scratch as shown in the following example: /* Setup the DMD temperature sensor for temperature mode */ vDmdTs_RunForTemp( 3 );...
  • Page 48: Encoding Module

    AN370 7.4. Encoding Module The encoding module provides predefined and customer configurable mechanism for input data conversion for the transmission ready data to be written to the ODS for transmission. There are 3 predefined encodings: none (NRZ), Manchester, and 4 bit to 5 bit encoding. Then users can provide their own functions for custom encoding. The encoding functions in this module are provided to a user as a convenience, but they will not be usually called by the user in the main application.
  • Page 49 AN370 7.4.3. 4 Bit to 5 Bit Encoding The following table is used for 4 bit to 5 bit encoding. When the last bit of the previously encoded 5 bit value was a 1 the output for the next 5 bit value is an inversion of the output listed below. Keep in mind that the least significant bit of the output is put onto the PA first.
  • Page 50 AN370 7.4.4. Custom Encoding The users can provide their own byte encoding. The user will write a custom encoding function and pass a pointer to that function when calling the vStl_EncodeSetup() function. The customer encoding function can encode an input byte to up to 8 bytes of data to be transmitted to the channel if the user is using vStl_SingleTxLoop(). After the custom encoding function is incorporated into the system then the vStl_SingleTxLoop () function will call the custom encoding function with proper pointer to the reserved 8 byte array.
  • Page 51 AN370 Outputs: pboEncodedBytes: (pointer to BYTE in XDATA) Up to 8 valid encoded bytes in output array. Valid encoded array size: (BYTE): Number of bytes in the output array pboEn- codedBytes which are valid after encoding. Valid values are 1 through 8. Any other return value will result in system instability.
  • Page 52 AN370 vEnc_Set4b5bLastBit Description: Sets the initial value of the bit that the 4b5b encoding references as the last bit of the previously encoded group of 5. The encoding of each group depends on the last bit of the previously encoded group. This function must be called before each frame trans- mission when using the 4b5b encoding.
  • Page 53: Frequency Counter Module

    AN370 7.5. Frequency Counter Module This module is responsible for interfacing to the frequency counter (FC). See “AN526: Si4010 API Additional Library Description” for more details 7.5.1. Frequency Counter Key Terms Table 9 lists key terms used in describing the Frequency Counter (FC) module.
  • Page 54 AN370 Remaining bits are unused and can have any value. Value 0 is recommended. biFcInterval: (BYTE) Controls the number of interval clock cycles during which the divider clock cycles are counted. The biFcInterval value is not the actual num- ber of interval clock cycles used. The actual number of interval clock cycles is cal- culated by the following equation: Ninterval_cycles = (2 + biFcInterval[0]) * 2biFcInterval[5:1] Example: An argument of 17 = 0x11 yields the following:...
  • Page 55 AN370 Outputs: None lFc_GetCount Description: Returns the latest value of the frequency counter. To ensure a correct reading vFc_PollDone() should be called prior to a call to this function. This function can be called any time to get the “on the fly” reading of the frequency counter. Inputs: None Outputs:...
  • Page 56: Frequency Casting Module

    AN370 7.6. Frequency Casting Module This module is responsible for adjusting the output frequency to the desired value before transmission and setting up parameters which allow for temperature compensation during transmission inside the Single Tx Loop (see Stl module). It is also responsible for optional output frequency calibration using crystal oscillator. 7.6.1.
  • Page 57 XO will be stabilizing while the device is going through the boot process to save time in the main application. See bit4 of SFR PROT3_CTRL in the Si4010 data sheet and the corresponding XO Early Enable checkbox on the NVM programmer GUI.
  • Page 58 AN370 est rate, 24MHz. The original clock rate is restored before exiting. The frequency calculation is controlled by the fact whether the crystal oscillator is enabled or not. The function checks the value of the bXO_CTRL.XO_ENA bit. If the XO is enabled, it is used for frequency tuning.
  • Page 59 Description: Takes the desired FSK deviation and adjusts the actual FSK deviation needed based on the results of frequency casting. It is to be called after each call to vFCast_Tune(). The input to this function is attained by using the Si4010 calculation spreadsheet, si4010_calc_regs.xls. It should be an application parameter.
  • Page 60: Hvram Module

    7.7. HVRAM Module The HVRAM module interfaces to the HVRAM. HVRAM in the Si4010 consists of 64 bits (8 bytes) of battery backed RAM. As long as the power is connected to the chip the HVRAM keeps its content. The content of the HVRAM is not affected by shutting down the chip by vSys_Shutdown() function.
  • Page 61: Multi-Time Programmable (Mtp) Memory Module

    AN370 7.8. Multi-time Programmable (MTP) Memory Module The multi-time programmable (MTP) memory (EEPROM) module functions deal with four 20-32 bit counters stored in the MTP non-volatile memory. In general the functions associated with the MTP module read and increment counters stored in the MTP memory. Actual counter values stored in the MTP are in special encoded format, not in the counter decimal representation.
  • Page 62 AN370 Counter Width MTP Bytes Max Value biNibbleCnt 20 bits 550k 24 bits 730k 28 bits 915k 32 bits 1040k If the user is using only 20 or 24-bit counters which require only 3 bytes of MTP storage then it is possible to have 5 such counters in the system with one byte to spare for independent user usage.
  • Page 63 AN370 7.8.5. MTP Module Functions lMtp_GetDecCount Description: Given the starting index of a counter in XDATA array this function returns the decoded content of the balanced counter as a 32-bit unsigned value. The user must call the pbMtp_Read() first before working with this function. Inputs: biIndex: (BYTE) Starting byte index of the counter in the MTP array.
  • Page 64 AN370 Outputs: None vMtp_SetDecCount Description: Converts an input decimal value to the internal counter representation for- mat used in the MTP. This function allows user to load predefined decimal value to the counter. The user must call the pbMtp_Read() first before working with this function. This function does not write the updated counter value into the actual MTP.
  • Page 65 AN370 However, the MTP module is rated to finish programming within 40 ms. For some appli- cations having a possible randomness in the time spent in this function might not be desir- able. Therefore, the user can limit the maximum number of cycles of the MTP programming. If the MTP is not programmed correctly after the user defined number of the cycles, the function returns an error.
  • Page 66 AN370 Inputs: None Outputs: None pbMtp_Read Description: Copy 128 bits out of the XDATA read only MTP output array abMTP_R- DATA[16] into the global 16-byte XDATA RAM array. The function returns a pointer to XDATA to the head of the internal RAM array. This function calls the vMtp_Strobe() function to latch the internal MTP content to its output registers.
  • Page 67: Battery Voltage Measurement Module

    AN370 7.9. Battery Voltage Measurement Module This module measures unloaded and loaded battery voltage. 7.9.1. Battery Measurement Module Functions iMVdd_Measure Description: Measures the battery voltage. It can be used in one of two modes. 1. If biWait == 0 then it measures the battery voltage when the battery is loaded with current user application.
  • Page 68 AN370 called to set the PA current according to the required transmission parameters. The temperature sensor demodulator DMD interrupt will be forcibly disabled at the end of the measurement: EDMD = 0; The user needs to take this into account. When using the Silicon Labs IDE for debugging it is required that the user uses the Step Over (F10) toolbar button and neither the Step (F11) nor Multiple Step toolbar but- tons when stepping over this function.
  • Page 69: Non-Volatile Memory (Nvm) Copy Module

    4 kB of RAM where the code can be run from. For details on the overlay technique see “AN518: Si4010 Memory Overlay Technique" application note. Extremely frequent read of the NVM can cause wear out failure of the memory. This phenomenon should only be considered in the rare case of more or less continuous boot or overlay read of the NVM.
  • Page 70 AN370 WORDwiNvmAddr /*------------------------------------------------------------- FUNCTION DESCRIPTION: Load one overlay block from NVM. *------------------------------------------------------------- *------------------------------------------------------------- VARIABLES: BYTEbStatus; /* Return bNvm_CopyBlock status */ *------------------------------------------------------------- vNvm_McEnableRead(); /* Enable analog hardware and NVM for read */ vNvm_SetAddr( wiNvmAddr ); /* Set the NVM block first address */ bStatus = bNvm_CopyBlock();...
  • Page 71 AN370 7.10.1. Non-Volatile Memory Copy Module Functions vNvm_SetAddr Description: Sets the NVM address where the next invocation of bNvm_CopyBlock() will start copying from NVM. The Silicon Labs provided NVM composer and burner will correctly format the user input IntelHEX files into the NVM block data structures required by this function.
  • Page 72 AN370 bNvm_CopyBlock Description: Copy a single NVM block of composed data from NVM. Based on the data destination address found in the NVM block this function can copy data to CODE/ XDATA 4.5KB RAM, as well as to the DATA/IDATA internal RAM region. Therefore, the user can use the NVM blocks to initialize the variables to desired initial val- ues by loading them from the NVM.
  • Page 73 AN370 vNvm_McEnableRead Description: Sets up the NVM related analog and digital device hardware for reading from NVM. It must be called once before the first call to vNvm_CopyBlock(). The hard- ware setup can take up to 30 µs. Inputs: None Outputs: None vNvm_McDisableRead...
  • Page 74: Output Data Serializer (Ods) Module

    The output data serializer (ODS) module is responsible for configuring the serializer, enabling and disabling it, and writing data to it. For setup parameters details see the Si4010 data sheet. The data bytes provided to the ODS are shifted out to the PA in a little endian fashion: The bit 0 of the byte is shifted out first.
  • Page 75 AN370 7.11.2. ODS Module Functions vOds_Setup Description: Set up the ODS serializer registers based on the value of the input structure of type tOds_Setup. All ODS related hardware registers with the exception of ODS_CTRL are cleared and overwritten by the new values. The function sets the following hardware registers: ODS_TIMING, ODS_RATEL, ODS_RATEH, ODS_WARM1, and ODS_WARM2.
  • Page 76 AN370 vOds_WriteData Description: Writes data byte to serializer. The least significant bit of this byte goes out of the PA first. Depending on the set group width not all 8 bits of this byte might be shifted out. Inputs: biWriteData: (BYTE) This byte is written to the serializer. Outputs: None Rev.
  • Page 77: Power Amplifier (Pa) Module

    The following table lists the members belonging to the tPa_Setup structure. For complete details on implications of structure members see descriptions of corresponding registers along with the Power Amplifier section in the Si4010 datasheet. The structure values should be calculated by the si4010_calc_regs.xls spreadsheet. See “AN547: Si4010 Calculator Spreadsheet Usage”...
  • Page 78 AN370 7.12.2. PA Module Functions vPa_Setup Description: Sets up the PA by writing contents of a tPa_Setup structure to PA global variables. These variables are then referenced by vPa_Tune(). The input structure items should be set based on the calculation results from si4010_cal- c_regs.xls spreadsheet.
  • Page 79 AN370 See “AN547: Si4010 Calculator Spreadsheet Usage” for more details /* Tune the PA with the current temperature */ vPa_Tune( iDmdTs_GetLatestTemp() ); Inputs: iiTemp: (int) Current temperature measurement from temperature sensor in inter- nal representation 220 bits/degC. It is the output of the vDmdTs_GetLatestTemp() function as shown in the example above.
  • Page 80: Single Transmission Loop (Stl) Module

    AN370 7.13. Single Transmission Loop (STL) Module The single transmission loop (STL) module is responsible for the following: 1. Setup for the data encoding during transmission. 2. Encoding the transmitted data on the fly. 3. Feeding the encoded data to the Output Data Serializer (ODS). 4.
  • Page 81 AN370 Value Header #define Description bEnc_NoneNrz_c No encoding, raw data byte. User can freely choose how many bits from each byte are going to be transmitted by setting tOds_Setup.bGroup- Width=(#bits-1). bEnc_Manchester_c Manchester encoding. Input byte is encoded into two bytes to be transmitted. Requires tOds_Setup.bGroupWidth=7.
  • Page 82 AN370 Outputs: pboEncodedBytes: (pointer to BYTE in XDATA) Up to 8 valid encoded bytes in output array. Valid encoded array size: (BYTE): Number of bytes in the output array pboEn- codedBytes which are valid after encoding. vStl_PreLoop Description: Sets up the chip for transmission. It requires the DMD ISR to be present in the system.
  • Page 83 AN370 Outputs: None vStl_SingleTxLoop Description: Transmits a single frame and keeps fine tuning the transmission frequency. This function performs two main tasks in a loop: 1. Take a byte from the input byte frame and pass it through the encoding. See vStl_EncodeSetup() for details.
  • Page 84 AN370 Description: Called after vStl_SingleTxLoop(). This function performs the following: 1. Disables ODS (EODS = 0) and DMD (EDMD = 0) interrupts. Note that ODS interrupt enable bit EODS is not currently being used by the API and is not enabled by any of the functions 2.
  • Page 85: System Module

    AN370 7.14. System Module This module contains a grouping of functions which perform tasks that are too specific and individual to justify creating an entire module for them. It is a collection of system support functions. 7.14.1. System Module Functions vSys_Setup Description: Responsible for setting any global configuration variables that the system functions might need.
  • Page 86 AN370 Turning on the bandgap will cause the vSys_BandGapLdo() function to wait 25 µs. Turn- ing on the LDO will cause the vSys_BandGapLdo() function to wait 6 µs. These wait times are required to let the voltages come to their stable levels. If the user application accesses the MTP or NVM memory, the BandGapLdo setting has to be 2 for the time of the MTP or NVM access, or can be set to 2 all time.
  • Page 87 AN370 bSys_GetRevId: Description: Returns the device revision ID. The number represents different die revi- sions. Current revision is 0x02. Inputs: None Outputs: Revision ID: (BYTE) Returns a byte with revision ID. lSys_GetProdId Description: Returns the Silicon Labs production ID. It is a 4 byte LWORD unique sequential number generated during production.
  • Page 88 AN370 BYTEbOldSetting; … /* Store the current system clock frequency setting */bOldSetting = SYSGEN; /* Set frequency for 3MHz .. 24MHz/2^3 */ vSys_SetClkSys( 3 ); … /* Restore the original system clock speed */ vSys_SetClkSys( bOldSetting ); Inputs: biClkSetting: (BYTE) Controls the divider of the LP system clock oscillator. fclk_sys = 24MHz / 2biClkSetting Only the bottom 3 bits of the biClkSetting are used, the rest is ignored.
  • Page 89 AN370 Outputs: Master Time: (LWORD) Current master time. vSys_IncMasterTime Description: Increments the master time. User application is responsible for calling this function in regular fashion. It is up to the user application to implement that, by using RTC timer or any of the TMR2 or TMR3 timers. The function just adds value to the master time variable.
  • Page 90 AN370 ing to biLedIntensity value. biLedIntensity LED Current LED off 0.37 mA 0.60 mA 0.97 mA Outputs: None vSys_LpOscAdj Description: Fine adjust the low power, 24MHz system clock, oscillator based on current chip temperature. The function requires that the temperature sensor demodulator ISR is present (DMD ISR). The function calls the vDmdTs_RunForTemp() function and waits for the first valid tem- perature sample.
  • Page 91 None Outputs: None bSys_GetBootStatus Description: Returns the boot status byte. For more information on the meaning of boot status see the boot section in the Si4010 data sheet. Inputs: None Outputs: Boot status: (BYTE) Status of the last boot sequence.
  • Page 92 AN370 vSys_FirstPowerUp Description: To be called at the beginning of the user application when the POW- ER_1ST_TIME field of the SYSGEN register is 1. It is the responsibility of the user appli- cation to check this bit. Boot routine does not do check the bit. The main task of this function is to force bandgap on while waiting for battery insertion voltage transients to take place.
  • Page 93 AN370 GEN_DIV to its original value. Overall system clock cycle count spent inside the function is determined by the following expression: Nclock_cycles = 32 + wiIntervalCount x 23 Since the function switches the internal system clock to the fastest speed, the actual delay time depends on the current system clock speed the function was entered with.
  • Page 94 AN370 where T_clk_sys_entry is the period of the system clock with which the function was entered and T_clk_sys_fast is the clock period of the system clock with SYSCLK_DIV = 0 setting. Nominally, it is 1/24 MHz = 41.667 ns. The longest delay this function can produce is 35 + 255 x 10 = 2585 cycles, resulting in 107 µs delay.
  • Page 95: Sleep Timer Module

    AN370 7.15. Sleep Timer Module The sleep timer (SleepTim) module interfaces to the 24 bit hardware decrementing counter driven by the sleep oscillator. This module assists the main application to enforce the duty cycle requirements of the ETSI specification. It also provides a way to set the sleep timer power switch which causes the chip to wake up when the timer reaches 0.
  • Page 96 Due to the fact that transmission times should be consistent and predictable in the Si4010 application, users should be able to define constants which represent the result of the above equation. These constants can then be used as wiInte- grand, and no calculation is necessary at runtime.
  • Page 97 AN370 smallest enforcement ratio is no less than E=0.001 (0.1%). That results in the maximum wiIntegrand value of 25600. Obviously, users can choose longer packet transmission time and different enforcement ratio. Any combination of values is possible as long as the resulting wiIntegread value is no greater than 65535.
  • Page 98: Simple Application Example

    AN370 8. Simple Application Example To illustrate how all the functions fall into place into a simple application the sample source code is included here. The user is advised to check the fcast_demo application provided. *------------------------------------------------------------------------------ VARIABLES: /* Structure for setting up the ODS .. must be in XDATA */ tOds_Setup xdata rOds_Setup;...
  • Page 99 AN370 vSys_Setup( 1 ); /* Setup the bandgap for working with the temperature sensor here */ vSys_BandGapLdo( 1 ); /* Setup the PA. * fAlpha and fBeta has to be set based on antenna configuration. * Chose a PA level and nominal cap. Both values come from * the calculation spreadsheet.
  • Page 100 AN370 /* Setup the STL encoding for none. No encode function therefore we * leave the pointer at NULL. */ vStl_EncodeSetup( bEnc_NoneNrz_c, NULL ); /* Generate the frame to use. Example array is fixed in CODE * as constant for this example. Assign the beginning of the array * to the pbFrameHead pointer.
  • Page 101 AN370 vFCast_FskAdj( 127 ); Now wait until there is a demodulated temperature sample while ( 0 == bDmdTs_GetSamplesTaken() ){} Tune the PA with the current temperature as an argument */ vPa_Tune( iDmdTs_GetLatestTemp() ); -- Run the Single Tx Loop */ vStl_PreLoop();...
  • Page 102: Document Change List

    AN370 OCUMENT HANGE Revision 0.3 to Revision 0.4  Updated table in "4.8. Files Needed for Building an Application" on page 16.  Updated Step 4 in "4.9. Compiling an Application" on page 18 Revision 0.4 to Revision 0.5  Descriptions of functions used only by the API internally were removed.
  • Page 103 AN370 OTES Rev. 1.0...
  • Page 104: Contact Information

    The products must not be used within any Life Support System without the specific written consent of Silicon Laboratories. A "Life Support System" is any product or system intended to support or sustain life and/or health, which, if it fails, can be reasonably expected to result in significant personal injury or death.

Table of Contents