Some troubles with I2S on DsPIC30F4013

General discussion on mikroPascal for dsPIC30/33 and PIC24.
Post Reply
Author
Message
bicross87
Posts: 8
Joined: 25 Feb 2009 10:48

Some troubles with I2S on DsPIC30F4013

#1 Post by bicross87 » 25 Feb 2009 10:57

Hi everyone,
First of all, please don't look at my bad English, I'm French...

I need to use I2S protocol to make my DsPIC30F4013 and my Texas PCM3001 codec working together. I'm using an EasyDsPic4 Development main board, and I just try, for the moment, to have a look at the I2S signal, without codec connected.

I'm able to activate DCI module and generate FSCK and COFS signals, but it's like the DCI module were reset after a very short time.
The Watchdog is disable (in the programmer configuration), and the DsPIC seems to be ok.

There is my code :

Code: Select all

#define	FCY		29491200
#define	FS              48000
#define	FCSCK		64*FS
#define	LOOPBACKMODE	0



int main (void);
void initialisation_DCI (void);
void DCIInterrupt(void);

int temp = 0;                  //On initialise la variable temporaire à 0

void main()
{
        ADPCFG = 0xFFFF;
        initialisation_DCI();  //On initialise le DCI
        while(1);
}



/*Phase de configuration du module I2S*/

void initialisation_DCI (void)
{
/*configuration des registres DCICON1*/
	DCICON1bits.CSCKD = 0;
//la pin CSCK en sortie, C'est le maitre qui impose l'horloge, ici, le DsPIC

	DCICON1bits.CSCKE = 1;
//changement des données sur flanc down, échantillonnage sur flanc up

	DCICON1bits.COFSD = 0;
//la pin COFS en sortie, c'est le maitre qui impose la sélection gauche droite,
//ici, le DsPIC

	DCICON1bits.UNFM = 0;
//Si les buffers d'envois ne sont pas raffraichi après transmission, on
//envoie des zeros

	DCICON1bits.CSDOM = 0;
//la pin CSDO(sortie) est gardée à l'état bas durant les time-slots inactifs

        DCICON1bits.DJST = 0;
//données transmises un bit après le Frame Sync pulse

	DCICON1bits.COFSM = 1;
//Frame Sync Signal configuré pr l'I2S

        DCICON1bits.DLOOP = 0;
//désactive le mode boucle qui recopie la sortie sur l'entrée

/*Configuration des registres DCICON2*/
	DCICON2bits.BLEN = 1;
//active les 2 buffers pr TX(transmitions) et RX(Réceptions)
	DCICON2bits.COFSG = 0;
//Frame Sync Generator configuré pour 2 mots par frame

	DCICON2bits.WS = 15;
//configure la longueur des mot en 16bits

/*Configuration des registres DCICON3*/

	DCICON3 = FCY / (2*FCSCK - 1);
//on configure CSCK Bit Clock Frequency

/*Configuration du registre Transmit Slot Control*/

        TSCONbits.TSE0 = 1;
//Transmition sur Time Slot 0

	TSCONbits.TSE1 = 0;
//pas de Transmition sur Time Slot 1

/*Configuration du registre Receiver Slot Control*/

	RSCONbits.RSE0 = 1;
//Reception sur Time Slot 0

	RSCONbits.RSE1 = 0;
//pas de Reception sur Time Slot 1

        IEC2bits.DCIIE = 1;
//Nettoie le DCI Interrupt Flag

        IFS2bits.DCIIF = 0;
//active DCI ISR processing

	DCICON1bits.DCIEN = 1;
//mise en route du module DCI
}

/*Fin de la phase de configuration*/



/*interruption pour la récéption et l'envoi */
void DCIInterrupt(void)
{
	//temp = RXBUF0;          //Stockage dans variable temp
	//temp = RXBUF1;
	TXBUF0 = 0x0A0A;	//Envoi de donnée connues
	TXBUF1 = 0x0101;
}
/*Fin de l'interruption*/
Sorry, commentary are in French !
Sadly, I can't take a screenshot of my oscilloscope, and it's quiet difficult to explain, but after a complete period of COFS, COFS and FSCK are falling down for about 20µS (Depending of the oscillator frequency), and it's starting again !

How disable the watchdog for sure in software ?
Someone has an idea about the matter ?

Thanks a lot,
Kevin

bicross87
Posts: 8
Joined: 25 Feb 2009 10:48

#2 Post by bicross87 » 25 Feb 2009 11:53

oups, I've done a mistake !
There is no pascal, but C, here !

Post Reply

Return to “mikroPascal for dsPIC30/33 and PIC24 General”