中级
30 分钟

使用Si4731和MK64FN1M0VDC12探索您喜爱的旋律

从AM的深情节拍到FM的活力曲调

AM/FM Click with Clicker 2 for Kinetis

已发布 6月 24, 2024

点击板

AM/FM Click

开发板

Clicker 2 for Kinetis

编译器

NECTO Studio

微控制器单元

MK64FN1M0VDC12

沉浸在声音的交响乐中,我们的收音机接收器打开了电波,将丰富的AM和FM音乐直接带到您的耳中。

A

A

硬件概览

它是如何工作的?

AM/FM Click基于Si4731,这是一款来自Silicon Labs的数字CMOS AM/FM收音机接收IC,它集成了从天线输入到数字音频输出的完整广播调谐器和接收功能。Si4731的音频信号通过Texas Instruments的LM4910 - 一个输出无电容立体声35mW耳机放大器,传送到板上的迷你3.5毫米母插孔。这样,用户可以直接将耳机插入Click板™,无需任何外部放大器。Si4731 IC利用Silicon Labs经验证的数字低中频(IF)架构,为消费电子应用提供具有高TDMA噪声免疫性、优越的广播性能和高保真音频功率放大功能的经济

高效的数字音频平台。音频信号经过处理以具有最佳动态特性。集成的DSP还处理信号的立体声MPX编码和FM调制。低级数字中频(IF)信号被滤除并发送到输出,通过高分辨率模数转换器(ADC)放大、滤波和数字化。这种先进的架构使Si4731能够进行信道选择、FM解调和立体声音频处理,达到比传统模拟架构更优越的性能。该Click设计用于通过I2C/双线控制接口进行通信。在选择双线模式时,SCLK引脚在RST引脚上升沿期间应保持在高电平,并保持高电平直到第一个启动条件之后。此外,在RST引脚上

升沿前的300nS内不得发生启动条件。双线总线模式仅使用SCL和SDA引脚进行通信。Si4731 IC具有接收信号测量能力。用于广播信号的天线也可以用于接受接收设备发送的信号。虽然它可以同时用于接收和发送信号,但天线不能同时在两种模式下工作。这一特性在校准Click板的发射功率时非常有用。此Click板™只能在3.3V逻辑电压级别下操作。在使用具有不同逻辑级别的MCU之前,必须进行适当的逻辑电压级别转换。此外,它配备了一个包含函数和示例代码的库,可以作为进一步开发的参考。

AM/FM Click hardware overview image

功能概述

开发板

Clicker 2 for Kinetis 是一款紧凑型入门开发板,它将 Click 板™的灵活性带给您喜爱的微控制器,使其成为实现您想法的完美入门套件。它配备了一款板载 32 位 ARM Cortex-M4F 微控制器,NXP 半导体公司的 MK64FN1M0VDC12,两个 mikroBUS™ 插槽用于 Click 板™连接,一个 USB 连接器,LED 指示灯,按钮,一个 JTAG 程序员连接器以及两个 26 针头用于与外部电子设备的接口。其紧凑的设计和清晰、易识别的丝网标记让您能够迅速构建具有独特功能和特性

的小工具。Clicker 2 for Kinetis 开发套件的每个部分 都包含了使同一板块运行最高效的必要组件。除了可以选择 Clicker 2 for Kinetis 的编程方式,使用 USB HID mikroBootloader 或外部 mikroProg 连接器进行 Kinetis 编程外,Clicker 2 板还包括一个干净且调节过的开发套件电源供应模块。它提供了两种供电方式;通过 USB Micro-B 电缆,其中板载电压调节器为板上每个组件提供适当的电压水平,或使用锂聚合物 电池通过板载电池连接器供电。所有 mikroBUS™ 本

身支持的通信方法都在这块板上,包括已经建立良好的 mikroBUS™ 插槽、重置按钮和几个用户可配置的按钮及 LED 指示灯。Clicker 2 for Kinetis 是 Mikroe 生态系统的一个组成部分,允许您在几分钟内创建新的应用程序。它由 Mikroe 软件工具原生支持,得益于大量不同的 Click 板™(超过一千块板),其数量每天都在增长,它涵盖了原型制作的许多方面。

Clicker 2 for Kinetis dimensions image

微控制器概述 

MCU卡片 / MCU

default

建筑

ARM Cortex-M4

MCU 内存 (KB)

1024

硅供应商

NXP

引脚数

121

RAM (字节)

262144

你完善了我!

配件

这些标准小型立体声耳机提供高质量的聆听体验,采用顶级的立体声电缆和连接器设计。它们具有通用兼容性,可以轻松连接到所有MIKROE mikromedia和多媒体板,是您电子项目的理想选择。这些耳机额定功率为100mW,提供从20Hz到20kHz的宽频范围内的清晰音频。其灵敏度为100 ± 5dB,阻抗为32Ω ± 15%,确保最佳音质。Φ15mm的扬声器提供清晰而身临其境的音效。这些耳机不仅具有成本效益且用途广泛,非常适合测试您的原型设备,提供经济可靠的音频解决方案,以补充您的项目。

AM/FM Click accessories image

使用的MCU引脚

mikroBUS™映射器

General-Purpose Output 1
PB2
AN
Reset
PB11
RST
I2C Address Selection
PC4
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
Shutdown
PA10
PWM
General-Purpose Output 2
PB13
INT
NC
NC
TX
NC
NC
RX
I2C Clock
PD8
SCL
I2C Data
PD9
SDA
NC
NC
5V
Ground
GND
GND
1

“仔细看看!”

Click board™ 原理图

AM/FM Click Schematic schematic

一步一步来

项目组装

Clicker 2 for PIC32MZ front image hardware assembly

从选择您的开发板和Click板™开始。以Clicker 2 for Kinetis作为您的开发板开始。

Clicker 2 for PIC32MZ front image hardware assembly
GNSS2 Click front image hardware assembly
Prog-cut hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
Board mapper by product7 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
Flip&Click PIC32MZ 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

软件支持

库描述

此库包含AM/FM Click驱动程序的API。

关键功能:

  • amfm_tune_up - 此功能将当前频率增加10 KHz

  • amfm_set_volume - 此功能设置音量级别,范围为0到63

  • amfm_get_stc - 此功能检查STC位状态

开源

代码示例

完整的应用程序代码和一个现成的项目可以通过NECTO Studio包管理器直接安装到NECTO Studio 应用程序代码也可以在MIKROE的GitHub账户中找到。

/*!
 * \file 
 * \brief AmFm Click example
 * 
 * # Description
 * This app simulate RADIO RECEIVER.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Initializes device.
 * 
 * ## Application Task  
 * Several additional functions are executed and printed over the terminal.
 * 
 * \author MikroE Team
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "amfm.h"

// ------------------------------------------------------------------ VARIABLES

static amfm_t amfm;
static log_t logger;

float aux;
uint8_t volume = 0x3F;
uint8_t mute_flag = 0;
uint8_t status;
uint16_t station_1 = 0;
uint16_t station_2 = 0;
uint16_t station_3 = 0;
uint16_t station_4 = 0;
uint16_t station_5 = 0;
uint16_t station_frequency = 0;
uint8_t memory = 0;

// ------------------------------------------------------- ADDITIONAL FUNCTIONS

void amfm_case_memorize ( )
{
    switch ( memory )
    {
        case 0 :
        {
            station_1 = station_frequency;
            memory += 1;
            log_printf( &logger, "> > > station 1 memorized\r\n" );
            break;
        }
        case 1 :
        {
            station_2 = station_frequency;
            memory += 1;
            log_printf( &logger, "> > > station 2 memorized\r\n" );
            break;
        }
        case 2 :
        {
            station_3 = station_frequency;
            memory += 1;
            log_printf( &logger, "> > > station 3 memorized\r\n" );
            break;
        }
        case 3 :
        {
            station_4 = station_frequency;
            memory += 1;
            log_printf( &logger, "> > > station 4 memorized\r\n" );
            break;
        }
        case 4 :
        {
            station_5 = station_frequency;
            memory = 0;
            log_printf( &logger, "> > > station 5 memorized\r\n" );
            break;
        }
        default :
        {
            break;
        }
    }
    log_printf( &logger, "-----------------------------------------\r\n" );
}

void amfm_case_station_1 ( amfm_t *ctx )
{
    log_printf( &logger, "> > > tune station 1 \r\n" );
    amfm_tune_frequency( ctx, station_1 );
    log_printf( &logger, "> > > tune done \r\n" );
    aux = station_1 / 100.0;
    log_printf( &logger, "> > > frequency: %f MHz \r\n", aux );
    log_printf( &logger, "-----------------------------------------\r\n" );
}

void amfm_case_station_2 ( amfm_t *ctx )
{
    log_printf( &logger, "> > > tune station 2 \r\n" );
    amfm_tune_frequency( ctx, station_2 );
    log_printf( &logger, "> > > tune done \r\n" );
    aux = station_2 / 100.0;
    log_printf( &logger, "> > > frequency: %f MHz \r\n", aux );
    log_printf( &logger, "-----------------------------------------\r\n" );
}

void amfm_case_station_3 ( amfm_t *ctx )
{
    log_printf( &logger, "> > > tune station 3 \r\n" );
    amfm_tune_frequency( ctx, station_3 );
    log_printf( &logger, "> > > tune done \r\n" );
    aux = station_3 / 100.0;
    log_printf( &logger, "> > > frequency: %f MHz \r\n", aux );
    log_printf( &logger, "-----------------------------------------\r\n" );
}

void amfm_case_station_4 ( amfm_t *ctx )
{
    log_printf( &logger, "> > > tune station 4 \r\n" );
    amfm_tune_frequency( ctx, station_4 );
    log_printf( &logger, "> > > tune done \r\n" );
    aux = station_4 / 100.0;
    log_printf( &logger, "> > > frequency: %f MHz \r\n", aux );
    log_printf( &logger, "-----------------------------------------\r\n" );
}

void amfm_case_station_5 ( amfm_t *ctx )
{
    log_printf( &logger, "> > > tune station 5 \r\n" );
    amfm_tune_frequency( ctx, station_5 );
    log_printf( &logger, "> > > tune done \r\n" );
    aux = station_5 / 100.0;
    log_printf( &logger, "> > > frequency: %f MHz \r\n", aux );
    log_printf( &logger, "-----------------------------------------\r\n" );
}

void amfm_case_seek ( amfm_t *ctx )
{
    log_printf( &logger, "> > > seek \r\n" );
    amfm_seek( ctx );
    log_printf( &logger, "> > > seek done \r\n" );
    station_frequency =  amfm_get_channel( ctx );
    aux = station_frequency / 100.0;
    log_printf( &logger, "> > > frequency: %f MHz \r\n", aux );
    log_printf( &logger, "-----------------------------------------\r\n" );
}

void amfm_case_plus ( amfm_t *ctx )
{
    if ( volume < 63 )
    {
        volume += 1;
        amfm_set_volume( ctx, volume );
        log_printf( &logger, "> > > volume: %u \r\n", volume );
    }
    else
    {
        log_printf( &logger, "> > > volume: MAX \r\n" );
    }
    log_printf( &logger, "-----------------------------------------\r\n" );
}

void amfm_case_minus ( amfm_t *ctx )
{
    if ( volume > 0 )
    {
        volume -= 1;
        amfm_set_volume( ctx, volume );
        log_printf( &logger, "> > > volume: %u \r\n", volume );
    }
    else
    {
        log_printf( &logger, "> > > volume: MIN \r\n" );
    }
    log_printf( &logger, "-----------------------------------------\r\n" );
}

void amfm_case_mute ( amfm_t *ctx )
{
    if ( 0 == mute_flag )
    {
        amfm_mute( ctx );
        log_printf( &logger, "> > > mute ON \r\n" );
        mute_flag = 1;
    }
    else
    {
        amfm_unmute( ctx );
        log_printf( &logger, "> > > mute OFF \r\n" );
        mute_flag = 0;
    }
    log_printf( &logger, "-----------------------------------------\r\n" );
}

void amfm_case_tune_up ( amfm_t *ctx )
{
    amfm_tune_up( ctx );
    station_frequency = amfm_get_channel( ctx );
    aux = station_frequency / 100.0;
    log_printf( &logger, "> > > frequency: %f MHz \r\n", aux );
    log_printf( &logger, "-----------------------------------------\r\n" );
}

void amfm_case_tune_down ( amfm_t *ctx )
{
    amfm_tune_down( ctx );
    station_frequency = amfm_get_channel( ctx );
    aux = station_frequency / 100.0;
    log_printf( &logger, "> > > frequency: %f MHz \r\n", aux );
    log_printf( &logger, "-----------------------------------------\r\n" );
}

// ------------------------------------------------------ APPLICATION FUNCTIONS

void application_init ( void )
{
    log_cfg_t log_cfg;
    amfm_cfg_t cfg;

    /** 
     * 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.

    amfm_cfg_setup( &cfg );
    AMFM_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    amfm_init( &amfm, &cfg );

    Delay_ms ( 100 );
    status = amfm_init_device( &amfm );
    if ( 0 == status )
    {
        log_printf( &logger, "> > > app init done < < <\r\n" );
    }
    else if ( 1 == status )
    {
        log_printf( &logger, "> > >    timeout    < < <\r\n" );
    }
    Delay_ms ( 1000 );
    
    amfm_case_seek( &amfm );
    amfm_case_memorize( );
    Delay_ms ( 1000 );
    
    amfm_case_seek( &amfm );
    amfm_case_memorize( );
    Delay_ms ( 1000 );
    
    amfm_case_seek( &amfm );
    amfm_case_memorize( );
    Delay_ms ( 1000 );
    
    amfm_case_seek( &amfm );
    amfm_case_memorize( );
    Delay_ms ( 1000 );
    
    amfm_case_seek( &amfm );
    amfm_case_memorize( );
    Delay_ms ( 1000 );
    
    amfm_case_plus( &amfm );
    Delay_ms ( 1000 );
}

void application_task ( void )
{
    amfm_case_station_1( &amfm );
    // 10 seconds delay
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
       
    amfm_case_station_2( &amfm );
    // 10 seconds delay
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    
    amfm_case_station_3( &amfm );
    // 10 seconds delay
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    
    amfm_case_station_4( &amfm );
    // 10 seconds delay
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    
    amfm_case_station_5( &amfm );
    // 10 seconds delay
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
}

int main ( void ) 
{
    /* Do not remove this line or clock might not be set correctly. */
    #ifdef PREINIT_SUPPORTED
    preinit();
    #endif
    
    application_init( );
    
    for ( ; ; ) 
    {
        application_task( );
    }

    return 0;
}

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

额外支持

资源

喜欢这个项目吗?

'购买此套件' 按钮会直接带您进入购物车,您可以在购物车中轻松添加或移除产品。