Beginner
10 min

Ensure a crisp and clear musical experience that transcends expectations using Si4732 and PIC32MZ2048EFM100

Tune into timeless melodies: Your gateway to AM/FM musical bliss!

AM/FM 2 Click with Curiosity PIC32 MZ EF

Published Nov 12, 2023

Click board™

AM/FM 2 Click

Dev. board

Curiosity PIC32 MZ EF

Compiler

NECTO Studio

MCU

PIC32MZ2048EFM100

Experience the nostalgia of classic tunes and the freshness of modern beats with our radio solution, seamlessly delivering a spectrum of musical bliss from both AM and FM bands.

A

A

Hardware Overview

How does it work?

AM/FM 2 Click is based on the Si4732, a broadcast AM/FM/SE/LW/RDS radio receiver from Skyworks. It features TDMA noise immunity, superior radio performance, high-fidelity audio power amplification, advanced AN/FM seek tunning, automatic frequency control (AFC), and automatic gain control (AGC). It also features a digital FM stereo decoder, programmable de-emphasis, advanced audio processing, and seven selectable AM channel filters. The Si4732 integrates an RDS/RBDS processor, which allows embedding of small amounts of digital information in conventional FM radio broadcasts. The Si4732 can receive the FM band broadcast in a range of 64 up to 108MHz and AM band from 520 up to 1710KHz. In addition, the receiver supports the SW band (2.3 – 26.1 MHz) and LW band (153 – 279 KHz). The AM/FM 2 Click uses an SMA connector and

external antenna to receive both AM and LW radio signals, while it also comes with a PTH for usage with a wire antenna. The FM and SW bands use a 3.5mm audio jack and connected earphones as an antenna, although a wire antenna is left as an option over an additional PTH. The Si4732 can receive or transmit the FM signal over the antenna but can not use both modes simultaneously. The audio signal from the output of the Si4732 is brought to the onboard 3.5mm female audio jack over the LM4910, eliminating the need for any external amplifier. There are four selectable digital sample precisions (8, 16, 20, and 24 bits). The sample rate can be set between 320000 and 48000Hz. AM/FM 2 Click uses a standard 2-Wire I2C interface to communicate with the host MCU. The I2C address can be selected over the ADDR SEL jumper with 0 default position. In cases

where the AM reception is too strong, the front-end attenuators can be engaged using the GP1 pin. The radio receiver has interrupt abilities, which can be used over the GP2 pin. Both GP1 and GP2 are turned off over unpopulated R8 and R9 resistor jumpers. To use them, you should solder 0Ω resistors. There is also an additional RST pin for resetting the radio receiver. The LM4910 features a low-power consumption shutdown mode activated over the ENA pin with LOW logic. This Click board™ can only be operated with a 3.3V logic voltage level. The board must perform appropriate logic voltage level conversion before using MCUs with different logic levels. Also, this Click board™ comes equipped with a library containing easy-to-use functions and an example code that can be used as a reference for further development.

AM/FM 2 Click hardware overview image

Features overview

Development board

Curiosity PIC32 MZ EF development board is a fully integrated 32-bit development platform featuring the high-performance PIC32MZ EF Series (PIC32MZ2048EFM) that has a 2MB Flash, 512KB RAM, integrated FPU, Crypto accelerator, and excellent connectivity options. It includes an integrated programmer and debugger, requiring no additional hardware. Users can expand

functionality through MIKROE mikroBUS™ Click™ adapter boards, add Ethernet connectivity with the Microchip PHY daughter board, add WiFi connectivity capability using the Microchip expansions boards, and add audio input and output capability with Microchip audio daughter boards. These boards are fully integrated into PIC32’s powerful software framework, MPLAB Harmony,

which provides a flexible and modular interface to application development a rich set of inter-operable software stacks (TCP-IP, USB), and easy-to-use features. The Curiosity PIC32 MZ EF development board offers expansion capabilities making it an excellent choice for a rapid prototyping board in Connectivity, IOT, and general-purpose applications.

Curiosity PIC32MZ EF double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

PIC32

MCU Memory (KB)

2048

Silicon Vendor

Microchip

Pin count

100

RAM (Bytes)

524288

You complete me!

Accessories

These standard small stereo earphones offer a high-quality listening experience with their top-notch stereo cable and connector. Designed for universal compatibility, they effortlessly connect to all MIKROE mikromedia and multimedia boards, making them an ideal choice for your electronic projects. With a rated power of 100mW, the earphones provide crisp audio across a broad frequency range from 20Hz to 20kHz. They boast a sensitivity of 100 ± 5dB and an impedance of 32Ω ± 15%, ensuring optimal sound quality. The Φ15mm speaker delivers clear and immersive audio. Cost-effective and versatile, these earphones are perfect for testing your prototype devices, offering an affordable and reliable audio solution to complement your projects.

AM/FM 2 Click accessories image

Used MCU Pins

mikroBUS™ mapper

Amplifier Enable
RPB4
AN
Reset
RA9
RST
NC
NC
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
General-Purpose I/O
RPE8
PWM
General-Purpose I/O
RF13
INT
NC
NC
TX
NC
NC
RX
I2C Clock
RPA14
SCL
I2C Data
RPA15
SDA
NC
NC
5V
Ground
GND
GND
1

Take a closer look

Click board™ Schematic

AM/FM 2 Click Schematic schematic

Step by step

Project assembly

Curiosity PIC32MZ EF front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Curiosity PIC32 MZ EF as your development board.

Curiosity PIC32MZ EF front image hardware assembly
GNSS2 Click front image hardware assembly
Prog-cut hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
Curiosity PIC32 MZ EF MB 1 Access - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
Necto image step 5 hardware assembly
Necto image step 6 hardware assembly
Curiosity PIC32 MZ EF MCU Step hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Debug Image Necto Step hardware assembly

Track your results in real time

Application Output

1. Application Output - In Debug mode, the 'Application Output' window enables real-time data monitoring, offering direct insight into execution results. Ensure proper data display by configuring the environment correctly using the provided tutorial.

2. UART Terminal - Use the UART Terminal to monitor data transmission via a USB to UART converter, allowing direct communication between the Click board™ and your development system. Configure the baud rate and other serial settings according to your project's requirements to ensure proper functionality. For step-by-step setup instructions, refer to the provided tutorial.

3. Plot Output - The Plot feature offers a powerful way to visualize real-time sensor data, enabling trend analysis, debugging, and comparison of multiple data points. To set it up correctly, follow the provided tutorial, which includes a step-by-step example of using the Plot feature to display Click board™ readings. To use the Plot feature in your code, use the function: plot(*insert_graph_name*, variable_name);. This is a general format, and it is up to the user to replace 'insert_graph_name' with the actual graph name and 'variable_name' with the parameter to be displayed.

Software Support

Library Description

This library contains API for AM/FM 2 Click driver.

Key functions:

  • amfm2_seek_station - AM/FM 2 seek station function.

  • amfm2_tuning_freq - AM/FM 2 tuning frequency function.

  • amfm2_get_tuning_freq - AM/FM 2 get tuning frequency function.

Open Source

Code example

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.

/*!
 * @file main.c
 * @brief AM/FM 2 Click example
 *
 * # Description
 * This example demonstrates the use of the AM/FM 2 Click board™.
 * The app represents a radio tuner that supports worldwide AM/FM bands 
 * and has features such as automatic frequency control, seek station, and volume control.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * The initialization of I2C module and log UART.
 * After driver initialization, the app sets the default configuration 
 * and searches and memorizes for a valid frequency of the 5 radio stations.
 *
 * ## Application Task
 * This example demonstrates the use of the AM/FM 2 Click board™.
 * The application switches all 5 previously memorized radio frequencies every 10 seconds.
 * Results are being sent to the UART Terminal, where you can track their changes.
 *
 * @author Nenad Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "amfm2.h"

static amfm2_t amfm2;
static log_t logger;

static float mem_station_freq[ 5 ] = { 0 };
static uint8_t rsp_status = 0;

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    amfm2_cfg_t amfm2_cfg;  /**< Click config object. */

    /** 
     * Logger initialization.
     * Default baud rate: 115200
     * Default log level: LOG_LEVEL_DEBUG
     * @note If USB_UART_RX and USB_UART_TX 
     * are defined as HAL_PIN_NC, you will 
     * need to define them manually for log to work. 
     * See @b LOG_MAP_USB_UART macro definition for detailed explanation.
     */
    LOG_MAP_USB_UART( log_cfg );
    log_init( &logger, &log_cfg );
    log_info( &logger, " Application Init " );

    // Click initialization.
    amfm2_cfg_setup( &amfm2_cfg );
    AMFM2_MAP_MIKROBUS( amfm2_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == amfm2_init( &amfm2, &amfm2_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    if ( AMFM2_ERROR == amfm2_default_cfg ( &amfm2 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }
    Delay_ms ( 100 );
    
    log_printf( &logger, " Begins searching for a valid frequency...\r\n" );
    log_printf( &logger, "--------------------\r\n" );
    for ( uint8_t n_cnt = 0; n_cnt < 5; n_cnt++ )
    {
        if ( AMFM2_OK == amfm2_seek_station( &amfm2, &rsp_status ) )
        {
            if ( AMFM2_RSP_STATUS_CTS & rsp_status )
            {
                log_printf( &logger, " The search is done.\r\n" );
                if ( AMFM2_OK == amfm2_get_tuning_freq( &amfm2, &mem_station_freq[ n_cnt ] ) )
                {
                    log_printf( &logger, " Frequency: %.2f MHz \r\n", mem_station_freq[ n_cnt ] );
                    log_printf( &logger, "- - - - - - - - - - \r\n" );
                    Delay_ms( 100 );
                }
            }
        }
    }
    log_printf( &logger, "--------------------\r\n" );
    Delay_ms( 100 );
    
    if ( AMFM2_OK == amfm2_set_volume( &amfm2, AMFM2_SET_VOLUME_MAX, &rsp_status ) )
    {
        log_printf( &logger, " Set max volume \r\n" );
        Delay_ms( 100 );
    }
    
    log_info( &logger, " Application Task " );
    log_printf( &logger, "--------------------\r\n" );
    Delay_ms( 100 );
}

void application_task ( void ) 
{
    for ( uint8_t n_cnt = 0; n_cnt < 5; n_cnt++ )
    {
        if ( AMFM2_OK == amfm2_tuning_freq( &amfm2, mem_station_freq[ n_cnt ], &rsp_status ) )
        {
            log_printf( &logger, " FM Station %d \r\nFrequency: %.2f MHz\r\n", 
                       ( uint16_t ) ( n_cnt + 1 ), mem_station_freq[ n_cnt ] );
            log_printf( &logger, "--------------------\r\n" );
            Delay_ms( 10000 );
        }
    }
}

void main ( void ) 
{
    application_init( );

    for ( ; ; ) 
    {
        application_task( );
    }
}

// ------------------------------------------------------------------------ END

Additional Support

Resources

Love this project?

'Buy This Kit' button takes you directly to the shopping cart where you can easily add or remove products.