PDA

View Full Version : Help with ISD 4002, Pic16f818 and SPI ??



purkolator
- 9th February 2006, 19:37
Hello,
I am a relative newbie to pic programming and was very happy to find this great resource.

I am working on a project with the ISD 4002 sound chip. I plan to control it with a PIC16F818 via SPI. My problem is that I am a complete newbie to use of the SSP port (SPI in particular in this case). I wonder if there might be any code examples out there for controlling a 4002 via SPI with PicBasic?

thanks in advance for the help!
Brad Purkey

purkolator
- 5th March 2006, 23:06
OK, I will answer my own question in hopes that someone else might benefit from my research.

It seems that PBP doesn't do SPI per se, but you can brute force it by using shift out for the MOSI data. In my application I haven't really needed the MISO data yet, so I haven't gotten that far. Although the ISD is a 3v chip, there is no level translation needed for any connection except MISO. If used, MISO will need a simple level translation circuit between the ISD and the Pic (see the ISD Chipcorder application notes for details).

So, here is a test program that will record 5 seconds of audio and then play it back...


'================ISD 4002 RECORD AND PLAY TEST================
' Records 5 seconds of audio to an ISD4002 Chipcorder and
' then plays it play back
' note: MISO is not used in this test (if used, MISO is the
' only port that must have 3v-5v level translation-see ISD app notes).
' Pic is a 16f818

'===variables
SS var PortB.5 'SS chip select
MOSI var PortB.2 'SPI out to ISD
SCLK var PortB.4 'SPI clock
LED var PortA.0 'LED indicator

'====main program

GOSUB PWRUP
PAUSE 5
GOSUB RECORDIT
PAUSE 5000
GOSUB STOPIT
PAUSE 5
GOSUB PLAYIT
GOSUB BLINK 'blink the led when playback starts
PAUSE 5000
GOSUB BLINK 'blink the led twice when playback ends
GOSUB BLINK
GOTO SHTDWN

'====subroutines

RECORDIT:
LOW SS
SHIFTOUT MISO,SCLK,0,[$A000\16] 'record from loc
HIGH SS
High LED ' turn record led on
RETURN

PLAYIT:
LOW SS
SHIFTOUT MOSI,SCLK,0,[$E000\16]
HIGH SS
RETURN

STOPIT: ' stop recording
LOW SS
SHIFTOUT MOSI,SCLK,0,[$3000\16] 'stop ISD
HIGH SS
LOW LED
RETURN

PWRUP:
LOW SS
SHIFTOUT MOSI,SCLK,0,[$2000\16] 'power up ISD
HIGH SS
RETURN

BLINK:
HIGH LED
PAUSE 200
LOW LED
PAUSE 200
RETURN

SHTDWN:
LOW SS
SHIFTOUT MOSI,SCLK,0,[$5000\16] 'stop and power down ISD
HIGH SS
END



all best,
Brad