Sie sind auf Seite 1von 3

Date:28May2009

Author:DavidNienhiser/W9GFdavid@nienhiser.com
Subject:TestingtheISD17150Chipcoder/VoiceRecord&Playbackdevice

TestSetup

IhaveanISDCOB17150DemoBoardforISD17150connectedtoaMicrochip
18F2550PIC(Clockedat4mhz).Imanuallyrecordedandsavedonetestmessage
ontheDemoBoardusingthepushbuttonswitchesandmicrophoneontheDemo
Board.ThenranthetestcodefromwithintheMicrochipMPLABIDE.TheCcode
wascompiledwithMPLABC18v3.30.

ThisexampleusesSPIBitBangingIdidntusetheSPIhardwarebuiltintothe
18F2550(savingthatforalatertime).

ThewaveformswerecapturedusingaUSBeeSXLogicAnalyzer.

ConstantDefinitions:

#define
#define
#define
#define

TRUE
FALSE
INPUT
OUTPUT

1
0
1
0

#define
#define
#define
#define

CS
MOSI
MISO
SCLK

LATAbits.LATA2
LATCbits.LATC7
PORTBbits.RB0
LATBbits.LATB1

//Chip Select
//Master Out - Slave In
//Master In - Slave Out
//Clock

Setup/InitializationCode:

ADCON1=0x0f;
TRISAbits.TRISA2=OUTPUT;
TRISCbits.TRISC7=OUTPUT;
TRISBbits.TRISB0=INPUT;
TRISBbits.TRISB1=OUTPUT;

//
//
//
//
//

INTCON2bits.RBPU=0;

// Enable pullups

CS=1;
MOSI=0;
SCLK=1;

Disable Analog Inputs


CS/SS for Sound Chip
MOSI / SDO (SPI Serial Data Out)
MISO / SDI (SPI Serial Data In)
SCK (SPI Clock Output)

// Initial Condition for CS = TRUE


// Initial Condition for MOSI / SDO = TRUE
// Initial Condition for MISO / SCK = TRUE

SPIBitBangcode:

unsigned char WriteSPIByte(unsigned char value)


{
unsigned char temp,delay,retval,mask,counter;

mask=1;
retval=0;
MOSI=(value&mask?TRUE:FALSE);
delay+=3;
SCLK=0;
for(delay=0;delay<5;++delay)
;
SCLK=1;
for(delay=0;delay<5;++delay)
;
SCLK=0;
for(delay=0;delay<5;++delay)
;
if(MISO==TRUE)
//Look at Input
retval|=mask;
else
Nop();
mask=mask<<1;
for(counter=0;counter<7;++counter) {
MOSI=(value&mask?TRUE:FALSE);
delay+=3;
SCLK=1;
for(delay=0;delay<5;++delay)
;
SCLK=0;
delay+=3;
if(MISO==TRUE)
//Look at Input
retval|=mask;
else
Nop();
mask=mask<<1;
}
return(retval);
}

PowerUpCommand:

CS=FALSE;
++rv;
rv1=WriteSPIByte(0x01);
rv2=WriteSPIByte(0x00);
++rv;
CS=TRUE;
MOSI=0;
SCLK=1;

//
//
//
//
//
//
//
//
//
//

CS = 0
Short Delay
Issue Power up command
After this command:
rv1 = 0x4e
rv2 = 0x02
Short Delay
CS = 1
Initial Condition for SDO = TRUE
Initial Condition for SCK = TRUE

WaveformforPowerUpCommand

PlayfromCurrentPositionCommand:

CS=FALSE;
rv+=5;
rv17=WriteSPIByte(0x40);
rv18=WriteSPIByte(0x00);
rv+=5;
CS=TRUE;
MOSI=0;
SCLK=1;

//
//
//
//
//
//
//
//
//
//

CS = 0
Short Delay
Issue "Play from Current Position" command
After this command:
rv17 = 0x4e
rv18 = 0x02
Short Delay
CS = 1
Initial Condition for SDO = TRUE
Initial Condition for SCK = TRUE

WaveformforPlayfromCurrentPositionCommand

Das könnte Ihnen auch gefallen