MP3 Playa (p. trois)
After some more thinking, I've decided that we can simplify the communication.. I'm going to remove the bit banged I2C and replace it with the hardware I2C.. We can afford to multiplex the MSSP for both I2C as well as SPI use.. The SPI devices all have individual ENABLE lines while I2C devices will only respond if there is a valid START bit, which will never happen under SPI.. Also, since we're rarely using I2C, we can afford to share it with the SPI.. And, we can configure the I2C to run at 400kHz for the STA013.. the PIC I2C can run up to 1MHz..
The I2C will only be used for:
- Downloading the STA013 Config File during startup
- Changing the Volume & Balance
- Changing the Tone (Treble/Bass)
- Changing modes (Play/Stop/Pause/Resume)
Also, the startup sequence will be:
- Startup LCD (Display Splash)
- Detect MMC & Initialize MMC (SPI on, CRC off)
- Load personal settings from EEPROM (Playlist Pointer, Volume, Tone)
- Detect STA013 & Configure STA013 (I2C)
- Run FSM (STOP Mode)
The system will run in the following states (FSM):
Mode STOP PLAY PAUSE IDLE
KB Next Next Song Volume UP Next Song STOP
KB Play PLAY PAUSE Resume/PLAY STOP
KB Stop Off/IDLE STOP STOP STOP
KB Prev Prev Song Volume Down Prev Song STOP
It's simple and intuitive to use, I think...
Oh, and I've decided to implement a mini message queue.. This is to ensure that the communications transfers do not get mixed up during interrupt service calls.. Simply put, when an interrupt happens, the interrupt service routine checks what kind of interrupt it is and places a value into the message queue.. Then, it exits the interrupt routine.. In the main program loop, the FSM will check on the queue to determine if anything happened.. If not, it will switch to IDLE Mode.. Else, it will take action depending on the queue message.. This way, we've got an event-driven PIC programme!!! And during non essential periods, the PIC is in low power mode.. It will only SLEEP when the user asks it to..
Till next time..
No comments:
Post a Comment