PU2CLR RDA5807 Arduino Library 1.1.9
Arduino Library for RDA5807 Devices - By Ricardo Lima Caratti
Loading...
Searching...
No Matches
FM Tune Functions

Functions

void RDA5807::setFrequencyToBeginBand ()
 Tunes the receiver at the first channel/frequency of the current band.
 
void RDA5807::setFrequencyToEndBand ()
 Tunes the receiver at the last channel/frequency of the current band.
 
uint16_t RDA5807::getMaximunFrequencyOfTheBand ()
 gets the maximun frequency of the current band
 
uint16_t RDA5807::getMinimumFrequencyOfTheBand ()
 gets the minimum frequency of the current band
 
uint8_t RDA5807::getBand ()
 Returns the current band.
 
uint8_t RDA5807::getSpace ()
 Returns the current Band Space.
 
bool RDA5807::isFmTrue ()
 Returns true if the current channel is a station.
 
bool RDA5807::isFmReady ()
 Returns true if the FM is ready.
 
void RDA5807::setSoftBlendEnable (bool value)
 Sets Soft Blend.
 
void RDA5807::setAFC (bool value)
 Sets AFC true or false.
 
void RDA5807::setChannel (uint16_t channel)
 Sets the channel.
 
void RDA5807::setFrequency (uint16_t frequency)
 Sets the frequency.
 
void RDA5807::setDirectFrequency (uint16_t frequency)
 Sets the frequency using the reg08 (direct frequency)
 
void RDA5807::setFrequencyMode (uint8_t value)
 Sets the frequency mode. If 1, then freq setting changed.
 
void RDA5807::setFrequencyUp ()
 Increments the current frequency.
 
void RDA5807::setFrequencyDown ()
 Decrements the current frequency.
 
uint16_t RDA5807::getFrequency ()
 Gets the current frequency.
 
uint16_t RDA5807::getRealChannel ()
 Gets the current channel stored in 0x0A status register.
 
uint16_t RDA5807::getRealFrequency ()
 Gets the current frequency bases on the current channel.
 
void RDA5807::seek (uint8_t seek_mode, uint8_t direction)
 Seek function.
 
void RDA5807::seek (uint8_t seek_mode, uint8_t direction, void(*showFunc)())
 Seek function.
 
void RDA5807::setSeekThreshold (uint8_t value)
 Sets RSSI Seek Threshold.
 
void RDA5807::setBand (uint8_t band=0)
 Sets the FM band. See table below.
 
void RDA5807::setBand3_50_65_Mode (uint8_t band3Mode)
 Sets the band 3 mode: 50 to 65 MHZ or 65 to 76 MHz.
 
uint8_t RDA5807::getBand3Status ()
 Gets the status of the Band3.
 
void RDA5807::setSpace (uint8_t space=0)
 Sets the FM channel space.
 
void RDA5807::setStep (uint8_t step=100)
 Sets the FM Step;.
 
void RDA5807::setFmDeemphasis (uint8_t de)
 Sets De-emphasis.
 

Detailed Description

FM Tune

Function Documentation

◆ getBand()

uint8_t RDA5807::getBand ( )
inline

Returns the current band.

See also
FM Band table
Returns
uint8_t

◆ getBand3Status()

uint8_t RDA5807::getBand3Status ( )

Gets the status of the Band3.

Gets the status of the Band3

Returns
1 if setup is 65 to 76 MHz; 0 if setup is 50 to 65 MHz

◆ getFrequency()

uint16_t RDA5807::getFrequency ( )

Gets the current frequency.

Returns
uint16_t

◆ getMaximunFrequencyOfTheBand()

uint16_t RDA5807::getMaximunFrequencyOfTheBand ( )
inline

gets the maximun frequency of the current band

Returns
the last valid frequency of the current band
See also
setFrequency, getFrequency, setFrequencyToBeginBand, setFrequencyToEndBand, getRealFrequency, getMaximunFrequencyOfTheBand, getMinimumFrequencyOfTheBand

◆ getMinimumFrequencyOfTheBand()

uint16_t RDA5807::getMinimumFrequencyOfTheBand ( )
inline

gets the minimum frequency of the current band

Returns
the first valid frequency of the current band
See also
setFrequency, getFrequency, setFrequencyToBeginBand, setFrequencyToEndBand, getRealFrequency, getMaximunFrequencyOfTheBand, getMinimumFrequencyOfTheBand

◆ getRealChannel()

uint16_t RDA5807::getRealChannel ( )

Gets the current channel stored in 0x0A status register.

See also
setChannel, setFrequency, setBand, setSpace
RDA5807M - SINGLE-CHIP BROADCAST FM RADIO TUNER - Rev.1.1–Aug.2015; pages 9 and 12.
Returns
uint16_t current channel value

◆ getRealFrequency()

uint16_t RDA5807::getRealFrequency ( )

Gets the current frequency bases on the current channel.

The current channel is stored in the 0x0A register. This value is updated after a tune or seek operation.

The current frequency can be calculated by the formula below

Band Formula
0 Frequency = Channel Spacing (kHz) x READCHAN[9:0]+ 87.0 MHz
1 or 2 Frequency = Channel Spacing (kHz) x READCHAN[9:0]+ 76.0 MHz
3 Frequency = Channel Spacing (kHz) x READCHAN[9:0]+ 65.0 MHz
See also
setChannel, setFrequency, setBand, setSpace
RDA5807M - SINGLE-CHIP BROADCAST FM RADIO TUNER - Rev.1.1–Aug.2015; pages 9 and 12.
Returns
uint16_t

◆ getSpace()

uint8_t RDA5807::getSpace ( )
inline

Returns the current Band Space.

Returns
uint8_t value (0 = 100kHz, 1 = 200kHz, 2 = 50kHz e 3 = 25kHz)

◆ isFmReady()

bool RDA5807::isFmReady ( )
inline

Returns true if the FM is ready.

Returns
true or false

◆ isFmTrue()

bool RDA5807::isFmTrue ( )
inline

Returns true if the current channel is a station.

Returns
true or false

◆ seek() [1/2]

void RDA5807::seek ( uint8_t  seek_mode,
uint8_t  direction 
)

Seek function.

look for next or previous station available. Example:

#include <RDA5807.h>
RDA5807 rx;
void setup() {
pinMode(4, INPUT_PULLUP); // Arduino pin 4 - Seek station down
pinMode(5, INPUT_PULLUP); // Arduino pin 5 - Seek station up
rx.setup(); // Starts the receiver with default parameters
rx.setFrequency(10390); // Tunes at 103.9 MHz - Switch to your local favorite station
}
void loop() {
if (digitalRead(4) == LOW) rx.seek(RDA_SEEK_WRAP,RDA_SEEK_DOWN);
if (digitalRead(5) == LOW) rx.seek(RDA_SEEK_WRAP,RDA_SEEK_UP);
delay(200);
}
#define RDA_SEEK_WRAP
Wrap at the upper or lower band limit and continue seeking.
Definition: RDA5807.h:57
#define RDA_SEEK_UP
Seek UP.
Definition: RDA5807.h:60
#define RDA_SEEK_DOWN
Seek Down.
Definition: RDA5807.h:59
KT0915 Class.
Definition: RDA5807.h:568
void setup(uint8_t clock_frequency=CLOCK_32K, uint8_t oscillator_type=OSCILLATOR_TYPE_PASSIVE, uint8_t rlck_no_calibrate=RLCK_NO_CALIBRATE_MODE_OFF)
Starts the device.
Definition: RDA5807.cpp:273
void seek(uint8_t seek_mode, uint8_t direction)
Seek function.
Definition: RDA5807.cpp:518
void setFrequency(uint16_t frequency)
Sets the frequency.
Definition: RDA5807.cpp:372
Parameters
seek_modeif 0, wrap at the upper or lower band limit and continue seeking; 1 = stop seeking at the upper or lower band limit
directionif 0, seek down; if 1, seek up.

◆ seek() [2/2]

void RDA5807::seek ( uint8_t  seek_mode,
uint8_t  direction,
void(*)()  showFunc 
)

Seek function.

Seeks a station up or down.

Seek up or down a station and call a function defined by the user to show the frequency during the seek process.

Seek begins at the current channel, and goes in the direction specified with the SEEKUP bit. Seek operation stops when a channel is qualified as valid according to the seek parameters, the entire band has been searched (SKMODE = 0), or the upper or lower band limit has been reached (SKMODE = 1).

The STC bit is set high when the seek operation completes and/or the SF/BL bit is set high if the seek operation was unable to find a channel qualified as valid according to the seek parameters. The STC and SF/BL bits must be set low by setting the SEEK bit low before the next seek or tune may begin.

The SEEK bit is set low and the STC bit is set high when the seek operation completes.

It is important to say you have to implement a show frequency function. This function have to get the frequency via getFrequency function.

Example:

SI470X rx;
void showFrequency() {
uint16_t freq = rx.getFrequency();
Serial.print(freq);
Serial.println("MHz ");
}
void loop() {
.
.
rx.seek(RDA_SEEK_WRAP, RDA_SEEK_UP, showFrequency); // Seek Up
.
.
}
Parameters
seek_modeSeek Mode; 0 = Wrap at the upper or lower band limit and continue seeking (default); 1 = Stop seeking at the upper or lower band limit.
directionSeek Direction; 0 = Seek down (default); 1 = Seek up.
showFuncfunction that you have to implement to show the frequency during the seeking process. Set NULL if you do not want to show the progress.

References RDA5807::waitAndFinishTune().

◆ setAFC()

void RDA5807::setAFC ( bool  value)

Sets AFC true or false.

Parameters
valuetrue or false

◆ setBand()

void RDA5807::setBand ( uint8_t  band = 0)

Sets the FM band. See table below.

FM band table

Value Decimal Description
00 0 87–108 MHz (US/Europe)
01 1 76–91 MHz (Japan)
10 2 76–108 MHz (world wide)
11 3 65 –76 MHz (East Europe) or 50-65MHz (see bit 9 of gegister 0x07)

if you are using the band 3 with 50 to 65 MHz setup, the setFrequencyUp, setFrequencyDown, setFrequencyToBeginBand and setFrequencyToEndBand

will not work properly. In this case, you have control the limits of the band by yourself.

#include <RDA5807.h>
void setup() {
rx.setup();
rx.setBand(2); // Sets band: 76–108 MHz (world wide)
rx.setFrequency(10390); // Tunes at 103.9 MHz
}
void loop() {
}
void setBand(uint8_t band=0)
Sets the FM band. See table below.
Definition: RDA5807.cpp:621
Parameters
bandFM band index. See table above.
See also
setBand3_50_65_Mode, getBand3Status

◆ setBand3_50_65_Mode()

void RDA5807::setBand3_50_65_Mode ( uint8_t  band3Mode)

Sets the band 3 mode: 50 to 65 MHZ or 65 to 76 MHz.

It works only for Band 3. So if you are on band 3 (default 65 – 76 MHz East Europe) you can change the range to 50-65MHz.

ATTENTION: The functions setFrequencyToBeginBand and setFrequencyToEnBand do not work for 50-65MHz setup. You have to control it by yourself.

ATTENTION: Also, you must control the band limits from 50 to 65 MHz. The setFrequencyUp and setFrequencyDown do not work properly.

Parameters
band3Modeif 1, 65 – 76 MHz; if 0, 50-65MHz

◆ setChannel()

void RDA5807::setChannel ( uint16_t  channel)

Sets the channel.

This method tunes the rteceiver in a given channel.

The channel can be calculated by using the follow formula

channel = (desired frequency - start band frequency) / space channel in use / 10.0);

See also
setFrequency, setBand, setSpace
RDA5807M - SINGLE-CHIP BROADCAST FM RADIO TUNER - Rev.1.1–Aug.2015; pages 9 and 12.
Parameters
channel

References RDA5807::waitAndFinishTune().

◆ setDirectFrequency()

void RDA5807::setDirectFrequency ( uint16_t  frequency)

Sets the frequency using the reg08 (direct frequency)

valid when frequency mode is 1

Parameters
frequency

◆ setFmDeemphasis()

void RDA5807::setFmDeemphasis ( uint8_t  de)

Sets De-emphasis.

Default is 75 μs (used in USA); 50 μs is used in Europe, Australia, Japan.

#include <RDA5807.h>
void setup() {
rx.setup();
rx.setFrequency(10390); // Tunes at 103.9 MHz
rx.setFmDeemphasis(1); // Sets to 50 μs. Used in Europe, Australia, Japan.
}
void loop() {
}
void setFmDeemphasis(uint8_t de)
Sets De-emphasis.
Definition: RDA5807.cpp:746
Parameters
de0 = 75 μs; 1 = 50 μs

◆ setFrequency()

void RDA5807::setFrequency ( uint16_t  frequency)

Sets the frequency.

Tunes the receiver at a given frequency. Example:

#include <RDA5807.h>
RDA5807 rx;
void setup() {
pinMode(4, INPUT_PULLUP); // Arduino pin 4 - Frequency Up
pinMode(5, INPUT_PULLUP); // Arduino pin 5 - Frequency Down
rx.setup();
rx.setFrequency(10390); // Tunes at 103.9 MHz
}
void loop() {
if (digitalRead(4) == LOW) rx.setFrequencyUp();
if (digitalRead(5) == LOW) rx.setFrequencyDown();
delay(200);
}
void setFrequencyUp()
Increments the current frequency.
Definition: RDA5807.cpp:424
void setFrequencyDown()
Decrements the current frequency.
Definition: RDA5807.cpp:439
Parameters
frequency- an integer with the frequency value (Example: 7600=76MHz, 10790 = 107,90MHz)
See also
setFrequencyUp, setFrequencyDown, getFrequency

◆ setFrequencyDown()

void RDA5807::setFrequencyDown ( )

Decrements the current frequency.

The drecrement uses the band space as step. See array: uint16_t fmSpace[4] = {20, 10, 5, 1};

◆ setFrequencyMode()

void RDA5807::setFrequencyMode ( uint8_t  value)

Sets the frequency mode. If 1, then freq setting changed.

Parameters
value( default = 0 or 1)

◆ setFrequencyToBeginBand()

void RDA5807::setFrequencyToBeginBand ( )
inline

Tunes the receiver at the first channel/frequency of the current band.

If the current band is 0, the lowest frequency is 87Mhz (8700)

See also
setFrequency, getFrequency, setFrequencyToEndBand, getRealFrequency, getMaximunFrequencyOfTheBand, getMinimumFrequencyOfTheBand

◆ setFrequencyToEndBand()

void RDA5807::setFrequencyToEndBand ( )
inline

Tunes the receiver at the last channel/frequency of the current band.

If the current band is 0, the highest frequency is 108MHz (10800)

See also
setFrequency, getFrequency, setFrequencyToBeginBand, getRealFrequency, getMaximunFrequencyOfTheBand, getMinimumFrequencyOfTheBand

◆ setFrequencyUp()

void RDA5807::setFrequencyUp ( )

Increments the current frequency.

The increment uses the band space as step. See array: uint16_t fmSpace[4] = {100/10, 200/10, 50/10, 25/10};

#include <RDA5807.h>
RDA5807 rx;
void setup() {
pinMode(4, INPUT_PULLUP); // Arduino pin 4 - Frequency Up
pinMode(5, INPUT_PULLUP); // Arduino pin 5 - Frequency Down
rx.setup();
rx.setFrequency(10390); // Tunes at 103.9 MHz
}
void loop() {
if (digitalRead(4) == LOW) rx.setFrequencyUp();
if (digitalRead(5) == LOW) rx.setFrequencyDown();
delay(200);
}
See also
setFrequency, getFrequency

◆ setSeekThreshold()

void RDA5807::setSeekThreshold ( uint8_t  value)

Sets RSSI Seek Threshold.

Parameters
value

◆ setSoftBlendEnable()

void RDA5807::setSoftBlendEnable ( bool  value)

Sets Soft Blend.

Parameters
valuetrue or false

◆ setSpace()

void RDA5807::setSpace ( uint8_t  space = 0)

Sets the FM channel space.

You can define the frequency step in kHz (see table below)

Channel space table

Value Decimal Description
00 0 100KHz
01 1 200KHz
10 2 50KHz
11 3 25KHz
#include <RDA5807.h>
void setup() {
pinMode(4, INPUT_PULLUP); // Arduino pin 4 - Frequency Up
pinMode(5, INPUT_PULLUP); // Arduino pin 5 - Frequency Down
rx.setup();
rx.setBandSpace(2); // 50 kHz Step
rx.setFrequency(10390); // Tunes at 103.9 MHz
}
void loop() {
if (digitalRead(4) == LOW) rx.setFrequencyUp(); // Up 50 kHz
if (digitalRead(5) == LOW) rx.setFrequencyDown(); // Down 50 kHz
delay(200);
}
Parameters
spaceFM channel space. See table above.
Todo:
make the space 01 (200kHz) work.
See also
setStep

◆ setStep()

void RDA5807::setStep ( uint8_t  step = 100)

Sets the FM Step;.

  • Converts the step frequency (25, 50, 100 or 200 kHz) to Space. Invalid values will be converted to 0 (100 kHz)
    Parameters
    step25, 50, 100 or 200 kHz
    Todo:
    Make the step 200kHz work well