Editor Version ×
recommended

Pro Edition

free

Brand new interactions and interfaces

Smooth support for design sizes of over 3W

devices or 10W pads

More rigorous design constraints, more

standardized processes

For enterprises, more professional users

Std Edition

Easy to use and quick to get started

The process supports design scales of 300

devices or 1000 pads

Supports simple circuit simulation

For students, teachers, creators

Ongoing

STD ATtiny13 TinyRadio

ATtiny13 TinyRadio

Project tags

License

CC-BY-SA 3.0

License: CC-BY-SA 3.0

Mode:

Mode

Editors' pick

Editors' pick

  • 6.3k
  • 0
  • 19
Update time: 2022-01-16 16:40:57
Creation time: 2020-11-15 14:56:24
Description

Description

# Overview TinyPocketRadio is a simple FM stereo radio based on ATtiny13A and RDA5807MP. It's powered by a CR2032 coin cell battery and can drive 32 Ohm headphones via the 3.5 mm audio plug. The board size is 38 x 23 mm. It has a power switch and three buttons: "Channel+", Volume-" and "Volume+ ". - Firmware (Github): https://github.com/wagiminator/ATtiny13-TinyPocketRadio ![pic1.jpg](https://raw.githubusercontent.com/wagiminator/ATtiny13-TinyPocketRadio/main/documentation/TinyPocketRadio_pic1.jpg) # Hardware The schematic is shown below: ![wiring.png](https://raw.githubusercontent.com/wagiminator/ATtiny13-TinyPocketRadio/main/documentation/TinyPocketRadio_Wiring.png) The low-cost RDA5807MP is a single-chip broadcast FM stereo radio tuner with fully integrated synthesizer, IF selectivity, RDS/RBDS and MPX decoder. The tuner uses the CMOS process, support multi-interface and require the least external component. All these make it very suitable for portable devices. # Software ## I²C Implementation The I²C protocol implementation is based on a crude bitbanging method. It was specifically designed for the limited resources of ATtiny10 and ATtiny13, but should work with some other AVRs as well. Due to the low clock frequency of the CPU, it does not require any delays for correct timing. In order to save resources, only the basic functionalities which are needed for this application are implemented. For a detailed information on the working principle of the I²C implementation visit [TinyOLEDdemo](https://github.com/wagiminator/attiny13-tinyoleddemo). ## Controlling the RDA5807 The FM tuner IC RDA5807MP is controlled via I²C by the ATtiny. It has six writable 16-bit registers (addresses 0x02 - 0x07) and six readable 16-bit registers (addresses 0x0A - 0x0F). Since no data has to be read from the device for this application, only the writable registers are used. The RDA5807 has two methods of write access, a sequential one in which the registers are always written starting from address 0x02 and an indexed method in which the register address is transferred first and then the content. Both methods are determined by different I²C addresses. To transfer the 16-bit register content, the high byte is sent first. The RDA5807 is controlled by setting or clearing certain bits in the respective registers. The details of the meanings of the individual registers can be found in the data sheet. The current register contents are saved in the RDA_regs array. ```c // RDA definitions #define RDA_ADDR_SEQ 0x20 // RDA I2C write address for sequential access #define RDA_ADDR_INDEX 0x22 // RDA I2C write address for indexed access #define R2_SEEK_ENABLE 0x0100 // RDA seek enable bit #define R2_SOFT_RESET 0x0002 // RDA soft reset bit #define R5_VOLUME 0x000F // RDA volume mask #define RDA_VOL 5 // start volume // global variables uint16_t RDA_regs[6] = { 0b1101001000000101, // RDA register 0x02 0b0001010111000000, // RDA register 0x03 0b0000101000000000, // RDA register 0x04 0b1000100010000000, // RDA register 0x05 0b0000000000000000, // RDA register 0x06 0b0000000000000000 // RDA register 0x07 }; // writes specified register to RDA void RDA_writeReg(uint8_t reg) { I2C_start(RDA_ADDR_INDEX); // start I2C for index write to RDA I2C_write(0x02 + reg); // set the register to write I2C_write(RDA_regs[reg] >> 8); // send high byte I2C_write(RDA_regs[reg] & 0xFF); // send low byte I2C_stop(); // stop I2C } // writes all registers to RDA void RDA_writeAllRegs(void) { I2C_start(RDA_ADDR_SEQ); // start I2C for sequential write to RDA for (uint8_t i=0; i> 8); // send high byte I2C_write(RDA_regs[i] & 0xFF); // send low byte } I2C_stop(); // stop I2C } // initialize RDA tuner void RDA_init(void) { I2C_init(); // init I2C RDA_regs[0] |= R2_SOFT_RESET; // set soft reset RDA_regs[3] |= RDA_VOL; // set start volume RDA_writeAllRegs(); // write all registers RDA_regs[0] &= 0xFFFD; // clear soft reset RDA_writeReg(0); // write to register 0x02 } // set volume void RDA_setVolume(uint8_t vol) { RDA_regs[3] &= 0xFFF0; // clear volume bits RDA_regs[3] |= vol; // set volume RDA_writeReg(3); // write to register 0x05 } // seek next channel void RDA_seekUp(void) { RDA_regs[0] |= R2_SEEK_ENABLE; // set seek enable bit RDA_writeReg(0); // write to register 0x02 } ``` ## Main Function The code utilizes the sleep mode power down function to save power. The CPU wakes up on every button press by pin change interrupt, transmits the appropriate command via I²C to the RDA5807 and falls asleep again. ```c // button pin definitions #define BT_SEEK PB0 #define BT_VOLM PB1 #define BT_VOLP PB2 #define BT_MASK (1
Design Drawing

Design Drawing

schematic diagram
1 /
PCB
1 /
The preview image was not generated, please save it again in the editor.
ID Name Designator Footprint Quantity BOM_Supplier Part BOM_Supplier BOM_Manufacturer BOM_Manufacturer Part
1 MSK-11027 KEY4 SW_SMD_MSK-11027 1 C21381 LCSC ReliaPro MSK-11027 Toggle Switches
2 100nH L1 L0603 1 C316302 LCSC Shenzhen Zhenhua Fu Elec CH1608HR10J(f)
3 TS24CA KEY2,KEY3,KEY1 SW-SMD_TS24CA 3 C393942 LCSC SHOU HAN TS24CA
4 10k R2,R1,R3 0603 3 C25804 LCSC UniOhm 0603WAF1002T5E
5 1k5 R4 0603 1 C22843 LCSC UniOhm 0603WAF1501T5E
6 CR2032 B1 BATTERY-3 1 C70377 LCSC Q&J CR2032-BS-6-1
7 PWR LED1 LED0603 1 C2286 LCSC KENTO KT-0603R
8 1.8k@100MHz FB2,FB1 L0603 2 C394465 LCSC Guangdong Fenghua Advanced Tech CBW160808U182T
9 PJ-313D AUDIO1 AUDIO-SMD_PJ-313D 1 C95463 LCSC HRO PJ-313D
10 ATtiny13A U1 SOP-8_150MIL 1 C14075 LCSC MICROCHIP ATTINY13A-SSU
11 ICSP H1 ICSP-PADS-SMALL 1 C358692 LCSC MINTRON MTP125-1203S1
12 24p C7 0603 1 C307503 LCSC Samsung Electro-Mechanics CL10C240JB8NNNC
13 100p C6 0603 1 C14858 LCSC SAMSUNG CL10C101JB8NNNC
14 4u7 C4,C5 0603 2 C19666 LCSC SAMSUNG CL10A475KO8NNNC
15 22n C3 0603 1 C21122 LCSC SAMSUNG CL10B223KB8NNNC
16 100n C1 0603 1 C14663 LCSC YAGEO CC0603KRX7R9BB104
17 47u C2 1206 1 C30300 LCSC FH 1206F476M160NT
18 32.768KHz X1 OSC-SMD_3215 1 C409356 LCSC TXC Corp AH03270014
19 RDA5807MP U2 SOP-8_150MIL 1 C167245 LCSC RDA Microelectronics RDA5807MP

Unfold

Project Attachments

Project Attachments

Empty
Project Members

Project Members

Target complaint
Related Projects
Change a batch
Loading...

Comment

Add to album ×

Loading...

reminder ×

Do you need to add this project to the album?

服务时间

周一至周五 9:00~18:00
  • 0755 - 2382 4495
  • 153 6159 2675

服务时间

周一至周五 9:00~18:00
  • 立创EDA微信号

    easyeda

  • QQ交流群

    664186054

  • 立创EDA公众号

    lceda-cn