Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Trouble with PIC18F2520 Master Vs. ISD4002 Slave using SPI

Status
Not open for further replies.

roberto.s

Newbie level 6
Joined
Feb 19, 2010
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Italy
Activity points
1,384
Hi,
I'm traying to drive an ISD4002 with a PIC18F2520 using the SPI.

I do any kind of test, the SPI work correctly if I use another PIC instad of the ISD,
data transfer was good; but when I use the ISD I really don't know how to test it....

This is my program, I think it's correct but probably it isn't.....:

#include <p18f2520.h>
#include <portb.h>
#include <spi.h>
#include <delays.h>

#pragma config OSC = HS
#pragma config WDT = OFF
#pragma config LVP = OFF
#pragma config PBADEN = OFF
#pragma config MCLRE = ON
//OSC = HS Impostato per lavorare ad alta frequenza
//WDT = OFF Disabilito il watchdog timer
//LVP = OFF Disabilito programmazione LVP
//PBADEN = OFF Disabilito gli ingressi analogici

#define POWERUP 0x20
#define SETPLAY 0xE0
#define PLAY 0xF0
#define SETREC 0xAF
#define REC 0xB0
#define STOP 0x30
#define POWERDOWN 0x10
#define ZERO 0x00
#define SPI_CS LATAbits.LATA5
#define LED LATAbits.LATA4
#define BUTTON PORTBbits.RB5


//variabili comuni ad uso contatori
unsigned int i,j,y,k;
char a,b;


// Prototipo di funzione
void High_Int_Event (void);

void high_interrupt (void){
// Salto per la gestione dell'interrupt
_asm GOTO High_Int_Event _endasm
}

#pragma code
#pragma interrupt High_Int_Event

// Funzione per la gestione dell'interruzione
void High_Int_Event (void){
//abilito la comunicazione seriale
OpenSPI(SPI_FOSC_64, MODE_00, SMPMID);
// Controllo che l'interrupt sia stato generato da PORTB
if (INTCONbits.RBIF == 1 ){
}
if(BUTTON==0){
Delay10KTCYx(10);
//creazione opzione PLAY-REC
for (i=0; i<60000&&BUTTON==0; i++){
}
if(i<60000){
//invio del comando di POWERUP
SPI_CS=0;
WriteSPI(POWERUP);
// Delay100TCYx(1);
WriteSPI(ZERO);
Delay1KTCYx(25);
//invio del comando di SETPLAY
WriteSPI(SETPLAY);
// Delay100TCYx(1);
WriteSPI(ZERO);
//invio del comando di PLAY
WriteSPI(PLAY);
// Delay100TCYx(1);
WriteSPI(ZERO);
SPI_CS=1;
//attesa dell'segnale di fine riproduzione
while (PORTBbits.RB0!=0){
LED=1;
Delay10KTCYx(1);
LED=0;
Delay1KTCYx(100);
}
//invio del comando di STOP
SPI_CS=0;
WriteSPI(STOP);
// Delay100TCYx(1);
WriteSPI(ZERO);
Delay1KTCYx(50);
//avvio della ricezione dei dati EOM ed indirizzo
a=ReadSPI();
// Delay100TCYx(1);
b=ReadSPI();
SPI_CS=1;
Delay10KTCYx(10);
}else{
//LED ON
LED=1;
//invio del comando di POWERUP
SPI_CS=0;
WriteSPI(POWERUP);
// Delay100TCYx(1);
WriteSPI(ZERO);
Delay1KTCYx(25);
//invio del comando di POWERUP
WriteSPI(POWERUP);
// Delay100TCYx(1);
WriteSPI(ZERO);
Delay1KTCYx(50);
//invio del comando di SETREC
WriteSPI(SETREC);
// Delay100TCYx(1);
WriteSPI(ZERO);
//invio del comando di REC
WriteSPI(REC);
// Delay100TCYx(1);
WriteSPI(ZERO);
SPI_CS=1;
Delay100TCYx(1);
//attesa rilascio del pulsante per finire la registrazione
while (BUTTON==0){
}
//invio del comando di STOP
SPI_CS=0;
WriteSPI(STOP);
// Delay100TCYx(1);
WriteSPI(ZERO);
Delay1KTCYx(50);
//avvio della ricezione dei dati EOM ed indirizzo
a=ReadSPI();
// Delay100TCYx(1);
b=ReadSPI();
SPI_CS=1;
//LED OFF
LED=0;
Delay10KTCYx(10);
}
}
CloseSPI();
// Resetto il flag d'interrupt per permettere nuove interruzioni
INTCONbits.RBIF = 0;
}

void main (void){
//Inizializzazione dei pin
// LATA = 0x00;
TRISA = 0b11001111;
LATAbits.LATA4 = 0;
// LATB = 0x00;
TRISB = 0xFF;
// LATC = 0x00;
TRISC = 0xFF;
//Abilita/Disabilita i resistori di pull-up sulla PORTB
//EnablePullups();
DisablePullups();
//Abilito le interruzioni su PORTB
INTCONbits.RBIE = 1;
//Abilito l'interrupt globale
INTCONbits.GIE = 1;
//Abilito l'interrupt periferiche
INTCONbits.PEIE = 1;
Delay100TCYx(1);
j=1000;
//Ciclo infinito
while(1){

}
}



Can anyone help me?
 

Re: Trouble with PIC18F2520 Master Vs. ISD4002 Slave using S

May be the problem is the timing of the comunication

the ISD datasheet tell 1KHz max frequency.

the SPI module can use the Timer2 that can be set with a prescaler of 1/16 and a post scaler of 1/16.

I'm using a crystal of 4MHz;

with all consideration at the moment I can obtain a bit rate of 3900Hz

How can I reduce the bit rate to less 1KHz?

Can I reduce the Clock frequency with some scaler at the #config OSC?
 

Re: Trouble with PIC18F2520 Master Vs. ISD4002 Slave using S

Hi,

Have never seen that chip before and only do assembler but a few things you might like to check into.

The isd4002 says it uses SPI but I think its a custom format that cannot be reproduced by the 2520s Spi module - you may have to use your own custom software to send and receive the data - I have a sensor that similarly states its spi but it only works with a suitable software routine, and not the pics spi module.


Apart from that what about the voltage interface between the two devices ?
Are you running the 2520 at 3v ? see the Electrical specifiations in the datasheet for the 2520 / 25LF20 and the osc frequency in fig 26.1 and 2

Most Pic spi so si lines also need pull up resistors, although none shown in that datasheet.

Hope some of that helps.
 

Re: Trouble with PIC18F2520 Master Vs. ISD4002 Slave using S

Hi,

thanks for your suggestion, I will look for it.

For the Power, I'm using a 3,3V.

In the datasheet of PIC18F2520 (fig.26.2) for my frequency operation 3,3V it's ok.

For the connection mode, I followed the schematich in the datasheet of ISD4002, it suggest to use a pull-up on the MISO line.

Now I will do some test.
 

Re: Trouble with PIC18F2520 Master Vs. ISD4002 Slave using S

Hi,

pull-up resistor on the MOSI line is not mentionated in the datasheets

The SCK signal must be under 1KHz, impossible to reaize with the internal timer of PIC, so I bilt this fool code to generate the transimission:

Code:
#include <p18f2520.h>
#include <portb.h>
#include <spi.h>
#include <sw_spi.h>
#include <delays.h>
#include <timers.h>
#include <math.h>

#pragma config OSC = HS
#pragma config WDT = OFF
#pragma config LVP = OFF
#pragma config PBADEN = OFF
#pragma config MCLRE = ON
//OSC = HS Impostato per lavorare ad alta frequenza
//WDT = OFF Disabilito il watchdog timer
//LVP = OFF Disabilito programmazione LVP
//PBADEN = OFF Disabilito gli ingressi analogici

#define POWERUP 0x20
#define SETPLAY 0xE0
#define PLAY 0xF0
#define SETREC 0xA0
#define REC 0xB0
#define STOP 0x30
#define POWERDOWN 0x10
#define ZERO 0x00
#define SPI_CS LATAbits.LATA5
#define LED LATAbits.LATA4
#define BUTTON PORTBbits.RB5
#define RITCOM Delay1KTCYx(1);

#define SPI_SDO LATCbits.LATC5
#define SPI_SDI PORTCbits.RC4
#define SPI_SCK LATCbits.LATC3

//variabili comuni ad uso contatori
unsigned int i,j,y;
char k;
char a[16],b[16];

// Prototipo di funzione
void High_Int_Event (void);
void Send_POWERUP (void);
void Send_SETPLAY (void);
void Send_PLAY (void);
void Send_SETREC (void);
void Send_REC (void);
void Send_STOP (void);
void Send_POWERDOWN (void);
void Send_ZERO (void);
void Read_INT (void);

void high_interrupt (void){
	// Salto per la gestione dell'interrupt
	_asm GOTO High_Int_Event _endasm
}

#pragma code
#pragma interrupt High_Int_Event

// Funzione per la gestione dell'interruzione
void High_Int_Event (void){
	// Controllo che l'interrupt sia stato generato da PORTB
	if (INTCONbits.RBIF == 1 ){
	}
	if(BUTTON==0){
		Delay10KTCYx(10);
		//creazione opzione PLAY-REC
		for (i=0; i<60000&&BUTTON==0; i++){
		}
		if(i<60000){
//invio del comando di POWERUP
			Send_POWERUP();
			Delay1KTCYx(25);
//invio del comando di SETPLAY
			Send_SETPLAY();
			Delay10TCYx(1);
//invio del comando di PLAY
			Send_PLAY();
//attesa dell'segnale di fine riproduzione
			while (PORTBbits.RB0!=0){
				LED=1;
				Delay10KTCYx(1);
				LED=0;
				Delay1KTCYx(100);
			}
//invio del comando di STOP
			Send_STOP();
			Delay1KTCYx(50);
//avvio della ricezione dei dati EOM ed indirizzo

			Delay1KTCYx(1);
		}else{
//LED ON
			LED=1;
//invio del comando di POWERUP
			Send_POWERUP();
			Delay1KTCYx(25);
//invio del comando di POWERUP
			Send_POWERUP();
			Delay1KTCYx(50);
//invio del comando di SETREC
			Send_SETREC();
			Delay10TCYx(1);
//invio del comando di REC
			Send_REC();
			Delay1KTCYx(1);
			//attesa rilascio del pulsante per finire la registrazione
			while (BUTTON==0){
			}
//invio del comando di STOP
			Send_STOP();
			Delay1KTCYx(50);
//avvio della ricezione dei dati EOM ed indirizzo

//LED OFF
			LED=0;
			Delay1KTCYx(1);
		}
	}
	// Resetto il flag d'interrupt per permettere nuove interruzioni
	INTCONbits.RBIF = 0;
}

void main (void){
	//Inizializzazione dei pin
	TRISA = 0b11001111;
	LATAbits.LATA4 = 0;
	LATAbits.LATA5 = 0;
	TRISB = 0xFF;
	TRISC = 0b11010111;
//Abilita/Disabilita i resistori di pull-up sulla PORTB
	DisablePullups();
//Abilito le interruzioni su PORTB
	INTCONbits.RBIE = 1;
//Abilito l'interrupt globale
	INTCONbits.GIE = 1;
//Abilito l'interrupt periferiche
	INTCONbits.PEIE = 1;
	Delay100TCYx(1);
	j=1000;
	SPI_CS=1;
	//Ciclo infinito
	while(1){
	
//	Send_SETREC();
//	LED=1;
//	Delay1KTCYx(1);
//	LED=0;
//	Delay1KTCYx(1);
	}
}


void Send_POWERUP (){
	SPI_CS=0;
//bit 0
	SPI_SCK=1;
	SPI_SDO=0;
	RITCOM;
	SPI_SCK=0;
	RITCOM;
//bit 1
	SPI_SCK=1;
	SPI_SDO=0;
	RITCOM;
	SPI_SCK=0;
	RITCOM;
//bit 2
	SPI_SCK=1;
	SPI_SDO=1;
	RITCOM;
	SPI_SCK=0;
	RITCOM;
//bit 3
	SPI_SCK=1;
	SPI_SDO=0;
	RITCOM;
	SPI_SCK=0;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PI_SCK=1;
	SPI_SDO=0;
	RITCOM;
	SPI_SCK=0;
	RITCOM;
//bit 12
	SPI_SCK=1;
	SPI_SDO=0;
	RITCOM;
	SPI_SCK=0;
	RITCOM;
//bit 13
	SPI_SCK=1;
	SPI_SDO=0;
	RITCOM;
	SPI_SCK=0;
	RITCOM;
//bit 14
	SPI_SCK=1;
	SPI_SDO=0;
	RITCOM;
	SPI_SCK=0;
	RITCOM;
//bit 15
	SPI_SCK=1;
	SPI_SDO=0;
	RITCOM;
	SPI_SCK=0;
	RITCOM;
	SPI_CS=0;
}

It does not work.
 

Re: Trouble with PIC18F2520 Master Vs. ISD4002 Slave using S

I got it!!!

Code was good, the mistake is in the bit sequence, it must be reverced:
from bit 0 to bit 15(Most Significative Bit);
and now it work.

At last but not least, watch out for the timing, the frequency must be under 1KHz.

Bye at all!!!
and good work!!!
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top