APPLICATION NOTE nRF24Z1 Controlled by External nAN24-10 MCU 1. Motivation The nRF24Z1 is a complex chip capable of transmitting digital audio signals, establishing links, and maintaining quality of service in internal firmware. However, the chip must be instructed which address and frequency scheme to use, when to go into power-down mode, and how to interact with a user interface and external chips. This document describes a software package that lets you access internal registers in the nRF24Z1 from a microcontroller (MCU). The software is written in C for easy development and porting. The program functions may be used stand-alone in an MCU program. A debug program is included so that you may call the functions from a terminal emulator running on a PC. 2. Limitations All functions in this document are written for nRF24Z1 firmware version 2.0 or later. The 2- wire slave interface (described below) is only supported in Engineering Sample 2 and later versions of the nRF24Z1 chip. Nordic Semiconductor is not responsible for the porting of the MCU program to other processor platforms. 3. Typical System The supporting MCU program is written for a system with user and control interfaces at the audio transmitter (ATX) and/or at the audio receiver (ARX). In this general case, the ATX 1 features the nRF24Z1 in transmit mode, an MCU, an EEPROM and a digital audio source (ADC, S/PDIF interface, I2S interface). The ARX features the nRF24Z1 in receive mode, an EEPROM, and a digital audio destination (amplifier, volume control, DAC etc). The system is controlled by the MCU in the ATX. (The MCU program may be adapted to go into an MCU in the ARX.) Here are some applications that may be realized with this general system: CD/MP3 player (ATX) with wireless headphones (ARX) HiFi stereo headphones with line-in on the ATX Wireless microphone 1 The EEPROM in the ATX is required for engineering sample versions of nRF24Z1. With the production-version of the chip, it is not strictly required, as initial register values may be loaded by the MCU program. However, it is recommended to design the ATX with room for the EEPROM. 4. Program Features Version 1.0 of the MCU program features functions for nRF24Z1 register access and debug. Later versions are in development, where a full API will be provided. Version 1.0 of the program is split in the following four parts: Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +47 72 89 89 00 - Fax +47 72 89 89 89 Revision: 1.0 Page 1 of 11 Date: 2005-07-25 APPLICATION NOTE nRF24Z1 Controlled by External MCU 1. General and nRF24Z1 specific functions in main.h, main.c, z1slaveio.h, z1slaveio.c 2. MCU specific functions in mcu.h, mcu atmega16.c 3. DAC specific functions in dac.h, dac max9850.c 4. Debug functions in uartdebug.h, uartdebug.c The program lets you control internal registers on a byte-by-byte level. It also features higher- level code to control the volume of a MAX9850 DAC and headphone amplifier. User interfaces and control interfaces to the audio source are not supported in this version. Most files are general purpose. There are four exceptions: Code that depends on the MCU and its architecture are in mcu xxxx.c, where xxxx represents the MCU name. As a programmer, you will need to consult the technical documentation of your MCU to port the required functions. mcu.h holds compiler and architecture dependant include lines. You will have to port this file as well. There should be no need to change the function definitions in mcu.h when you port the program to a different MCU. Code that depends on your DAC is collected in dac yyyy.c. You should not change dac.h. That file is included in the rest of the program. The DAC datasheet holds information about how to configure other DACs than the described MAX9850. makefile may have to be changed to work with your compiler. It also has to list which source files you want to compile. 4.1. General and nRF24Z1 Specific Functions A main()program initiates the necessary hardware and starts a debug interface. main.h includes global configuration settings. The most important setting is to select either the SPI or the 2-wire slave interface of the nRF24Z1 to be used with the MCU code. These are the nRF24Z1 specific functions in z1slaveio.h: char z1 singleread (char adr) Reads and returns a single byte from an internal register (adr) in nRF24Z1 using its SPI or 2- wire slave interface (and corresponding master interface of the MCU) void z1 singlewrite (char adr, char data) Writes a single byte (data) to an internal register (adr) in nRF24Z1 void z1 multiread (char startadr, char endadr) Reads multiple consecutive bytes (startadr through endadr) from nRF24Z1 internal registers into the global array slaveinbuf . void z1 multiwrite (char startadr, char endadr) Writes multiple consecutive bytes (startadr through endadr) into nRF24Z1 internal register from the global array slaveoutbuf . char z1 flagready(char flag) Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +47 72 89 89 00 - Fax +47 72 89 89 89 Revision: 1.0 Page 2 of 11 Date: 2005-07-25