Happy Christmas and Happy New Year wishes from Attiny13

While trying to open a chinese camera pen, unfortunately the PCB inside it got damaged. Few of the PCB traces got cut and it became useless. After few days, I removed an 8 pin IC with SO8 package from the PCB. I was curious to know what it is, so I googled the part number 25FW406A but I couldn’t find any exact match. I found some part number similar to that and I concluded that it is an SPI flash. Later I got a datasheet from ‘ON semiconductor’ for a similar part -LE25U40CMD which is a 4M-bit SPI flash memory. I soldered the IC on a common board, powered it with 3.3v and interfaced it to a TI stellaris launchpad via SPI port. According to the datasheet the SPI port need to be initialized in mode 0 or 3. I tried few commands listed in the datasheet and got proper response from the chip, the CHIP ID doesn’t matches but that is expected because it is not the same part. I wrote functions for erasing, reading and writing the flash memory and tested it successfully using the launchpad.
Happy Christmas and Happy New Year wishes from Attiny13
       Then I thought of making an audio player using this chip which can play 8K mono wav file for around 1 minute. I selected Attiny13 microcontroller for this project. It is always fun to do some thing with limited resources. Attiny13 MCU is having 1KB flash and 64 bytes RAM. Also it is an 8 pin MCU. There are 5 GPIOs. I don’t want to change the reset pin as a GPIO because I want to program it via ISP while developing the firmware.
       My requirements are,
            1> One PWM pin for audio out. [1 pin]
            2> SPI pins for interfacing with flash memory. (SO, SI, CS, SCK) [4 pins]
            3> UART communication for song update. [2 pins]
            4> Switch to select song loading mode [1 pin]

So all together 8 pins are required. But the controller have only 5 GPIOs. Out of this, PB0 is used as PWM for audio out. So I cannot use hardware SPI because PB0 is the MOSI pin for hardware SPI. So no other option, I have to use software SPI but it is not a problem. I used the other 4 pins for SPI. To update song in memory chip, I thought of using UART because it is the most popular way of communication between microcontroller and a PC, also most electronics hobbyist will have one usb to uart converter or an RS232 port and a MAX232 circuit. I used the same PWM pin as UART RX because it is having pin change interrupt feature. Also while flashing wav file, I don’t want to use the PWM function. Also it is the only free PIN which is not connected to the SPI port of the memory chip. Now I need a TX pin for sending ACK to the programmer and for proper handshaking while loading the song to memory chip. I used the SCK pin for this purpose. But SCK pin will toggle while communicating with the memory,
 
For more detail: Happy Christmas and Happy New Year wishes from Attiny13


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top