Forum: Mikrocontroller und Digitale Elektronik STM32F4 Discovery - Audiodac + I2S


von Cel (Gast)


Angehängte Dateien:

Lesenswert?

Hallo,
ich habe ein kleines bis mittelgroßes Problem, bei der Lösung könnt Ihr 
mir sicherlich helfen. Ich nehme alle Hinweise gerne an! Vielen Dank für 
eure Zeit und Mühe!

Ich probiere gerade ein Waveplayer zu schreiben für den 
STM32F407(benutze das Discoveryboard) mit der Entwicklungsumgebung SiSy 
in UML.

Das Problem beschreibt sich wie folgt, ich schicke Daten an den SPI3 
bzw.
I2S. Erst nach einer längeren Zeit (~1-2 Minuten) kann ich mit meinen, 
an den Klinkestecker angeschlossenen Kopfhörer einen Ton hören.

Meine Quellen sind: 
http://www.mind-dump.net/configuring-the-stm32f4-discovery-for-audio, 
das Manual des CS43L22 und das Reference Manual. Ich habe mir bereits 
das Beispiel von ST angeschaut und kann leider daraus keine sinnvollen 
Informationen für mich akquirieren.
Ich weiß auch nicht, ob ich einen Fehler bei der Initialisierung des 
Audiodacs oder des I2S gemacht habe. Jetzt zum Quellcode ( im Anhang 
findet sich ein SiSy-Archiv).

onStart
1
audiodac.init();
2
led2.on();
3
i2s.init();
4
led3.on();
5
waitMs(1000);
6
 
7
led3.on();
8
9
I2S_Cmd(SPI3, ENABLE);
10
11
while(1)
12
{
13
  if ((SPI_I2S_GetFlagStatus(SPI3, SPI_I2S_FLAG_TXE)))
14
  {
15
      i2s.Datasend(0xfff9);
16
      waitMs(3);
17
      i2s.Datasend(0x3);
18
      led4.toggle();
19
  }
20
}

audiodac.init
1
#define CORE_I2C_ADDRESS 0x33
2
#define CODEC_I2C_ADDRESS 0x94
3
4
#define CODEC_MAPBYTE_INC 0x80
5
#define CODEC_MAP_CHIP_ID 0x01
6
#define CODEC_MAP_PWR_CTRL1 0x02
7
#define CODEC_MAP_PWR_CTRL2 0x04
8
#define CODEC_MAP_CLK_CTRL  0x05
9
#define CODEC_MAP_IF_CTRL1  0x06
10
#define CODEC_MAP_IF_CTRL2  0x07
11
#define CODEC_MAP_PASSTHROUGH_A_SELECT 0x08
12
#define CODEC_MAP_PASSTHROUGH_B_SELECT 0x09
13
#define CODEC_MAP_ANALOG_SET 0x0A
14
#define CODEC_MAP_PASSTHROUGH_GANG_CTRL 0x0C
15
#define CODEC_MAP_PLAYBACK_CTRL1 0x0D
16
#define CODEC_MAP_MISC_CTRL 0x0E
17
#define CODEC_MAP_PLAYBACK_CTRL2 0x0F
18
#define CODEC_MAP_PASSTHROUGH_A_VOL 0x14
19
#define CODEC_MAP_PASSTHROUGH_B_VOL 0x15
20
#define CODEC_MAP_PCMA_VOL 0x1A
21
#define CODEC_MAP_PCMB_VOL 0x1B
22
#define CODEC_MAP_BEEP_FREQ_ONTIME 0x1C
23
#define CODEC_MAP_BEEP_VOL_OFFTIME 0x1D
24
#define CODEC_MAP_BEEP_TONE_CFG 0x1E
25
#define CODEC_MAP_TONE_CTRL 0x1F
26
#define CODEC_MAP_MASTER_A_VOL 0x20
27
#define CODEC_MAP_MASTER_B_VOL 0x21
28
#define CODEC_MAP_HP_A_VOL 0x22
29
#define CODEC_MAP_HP_B_VOL 0x23
30
#define CODEC_MAP_SPEAK_A_VOL 0x24
31
#define CODEC_MAP_SPEAK_B_VOL 0x25
32
#define CODEC_MAP_CH_MIX_SWAP 0x26
33
#define CODEC_MAP_LIMIT_CTRL1 0x27
34
#define CODEC_MAP_LIMIT_CTRL2 0x28
35
#define CODEC_MAP_LIMIT_ATTACK 0x29
36
#define CODEC_MAP_OVFL_CLK_STATUS 0x2E
37
#define CODEC_MAP_BATT_COMP 0x2F
38
#define CODEC_MAP_VP_BATT_LEVEL 0x30
39
#define CODEC_MAP_SPEAK_STATUS 0x31
40
#define CODEC_MAP_CHARGE_PUMP_FREQ 0x34
41
#define CODEC_RESET_PIN GPIO_Pin_4
42
lowlevelinit();
43
codec_ctrl_init();

lowlevelinit();
1
GPIO_InitTypeDef PinInitStruct;
2
GPIO_StructInit(&PinInitStruct);
3
4
I2C_InitTypeDef I2C_InitType;
5
6
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_GPIOB, ENABLE);
7
8
PinInitStruct.GPIO_Mode = GPIO_Mode_AF;
9
PinInitStruct.GPIO_OType = GPIO_OType_OD;
10
PinInitStruct.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_9;
11
PinInitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
12
PinInitStruct.GPIO_Speed = GPIO_Speed_50MHz;
13
GPIO_Init(GPIOB, &PinInitStruct);
14
15
GPIO_PinAFConfig(GPIOB, GPIO_PinSource6, GPIO_AF_I2C1);
16
GPIO_PinAFConfig(GPIOB, GPIO_PinSource9, GPIO_AF_I2C1);
17
18
RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1, ENABLE);
19
20
I2C_DeInit(I2C1);
21
I2C_InitType.I2C_ClockSpeed = 100000;
22
I2C_InitType.I2C_Mode = I2C_Mode_I2C;
23
I2C_InitType.I2C_OwnAddress1 = CORE_I2C_ADDRESS;
24
I2C_InitType.I2C_Ack = I2C_Ack_Enable;
25
I2C_InitType.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
26
I2C_InitType.I2C_DutyCycle = I2C_DutyCycle_2;
27
28
I2C_Cmd(I2C1, ENABLE);
29
I2C_Init(I2C1, &I2C_InitType);
30
31
32
// ResetPin des AudioDAC
33
{
34
Gpio port;
35
port.initStruct.GPIO_Pin   = CODEC_RESET_PIN;
36
port.initStruct.GPIO_Mode  = GPIO_Mode_OUT;
37
port.initStruct.GPIO_OType = GPIO_OType_PP;
38
port.initStruct.GPIO_PuPd  = GPIO_PuPd_DOWN;
39
port.initStruct.GPIO_Speed = GPIO_Speed_50MHz;
40
port.init(GPIOD);
codec_ctrl_init();
1
uint32_t delaycount;
2
uint8_t CodecCommandBuffer[5];
3
4
uint8_t regValue = 0xFF;
5
6
GPIO_SetBits(GPIOD, CODEC_RESET_PIN);
7
delaycount = 1000000;
8
while (delaycount > 0)
9
{
10
  delaycount--;
11
}
12
//keep codec OFF
13
CodecCommandBuffer[0] = CODEC_MAP_PLAYBACK_CTRL1;
14
CodecCommandBuffer[1] = 0x01;
15
send_codec_ctrl(CodecCommandBuffer, 2);
16
17
//begin initialization sequence (p. 32)
18
CodecCommandBuffer[0] = 0x00;
19
CodecCommandBuffer[1] = 0x99;
20
send_codec_ctrl(CodecCommandBuffer, 2);
21
22
CodecCommandBuffer[0] = 0x47;
23
CodecCommandBuffer[1] = 0x80;
24
send_codec_ctrl(CodecCommandBuffer, 2);
25
26
regValue = read_codec_register(0x32);
27
28
CodecCommandBuffer[0] = 0x32;
29
CodecCommandBuffer[1] = regValue | 0x80;
30
send_codec_ctrl(CodecCommandBuffer, 2);
31
32
regValue = read_codec_register(0x32);
33
34
CodecCommandBuffer[0] = 0x32;
35
CodecCommandBuffer[1] = regValue & (~0x80);
36
send_codec_ctrl(CodecCommandBuffer, 2);
37
38
CodecCommandBuffer[0] = 0x00;
39
CodecCommandBuffer[1] = 0x00;
40
send_codec_ctrl(CodecCommandBuffer, 2);
41
//end of initialization sequence
42
43
CodecCommandBuffer[0] = CODEC_MAP_PWR_CTRL2;
44
CodecCommandBuffer[1] = 0xAF;
45
send_codec_ctrl(CodecCommandBuffer, 2);
46
47
CodecCommandBuffer[0] = CODEC_MAP_PLAYBACK_CTRL1;
48
CodecCommandBuffer[1] = 0x70;
49
send_codec_ctrl(CodecCommandBuffer, 2);
50
51
CodecCommandBuffer[0] = CODEC_MAP_CLK_CTRL;
52
CodecCommandBuffer[1] = 0x81; //auto detect clock
53
send_codec_ctrl(CodecCommandBuffer, 2);
54
55
CodecCommandBuffer[0] = CODEC_MAP_IF_CTRL1;
56
CodecCommandBuffer[1] = 0x07;
57
send_codec_ctrl(CodecCommandBuffer, 2);
58
59
CodecCommandBuffer[0] = 0x0A;
60
CodecCommandBuffer[1] = 0x00;
61
send_codec_ctrl(CodecCommandBuffer, 2);
62
63
CodecCommandBuffer[0] = 0x27;
64
CodecCommandBuffer[1] = 0x00;
65
send_codec_ctrl(CodecCommandBuffer, 2);
66
67
CodecCommandBuffer[0] = 0x1A | CODEC_MAPBYTE_INC;
68
CodecCommandBuffer[1] = 0x0A;
69
CodecCommandBuffer[2] = 0x0A;
70
send_codec_ctrl(CodecCommandBuffer, 3);
71
72
CodecCommandBuffer[0] = 0x1F;
73
CodecCommandBuffer[1] = 0x0F;
74
send_codec_ctrl(CodecCommandBuffer, 2);
75
76
CodecCommandBuffer[0] = CODEC_MAP_PWR_CTRL1;
77
CodecCommandBuffer[1] = 0x9E;
78
send_codec_ctrl(CodecCommandBuffer, 2);

von Cel (Gast)


Lesenswert?

read_codec_register
1
uint8_t receivedByte = 0;
2
3
while (I2C_GetFlagStatus(I2C1, I2C_FLAG_BUSY))
4
{
5
  //just wait until no longer busy
6
}
7
8
I2C_GenerateSTART(I2C1, ENABLE);
9
while (!I2C_GetFlagStatus(I2C1, I2C_FLAG_SB))
10
{
11
  //wait for generation of start condition
12
}
13
14
I2C_Send7bitAddress(I2C1, CODEC_I2C_ADDRESS, I2C_Direction_Transmitter);
15
while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED))
16
{
17
  //wait for end of address transmission
18
}
19
20
I2C_SendData(I2C1, mapbyte); //sets the transmitter address
21
while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTING))
22
{
23
  //wait for transmission of byte
24
}
25
26
I2C_GenerateSTOP(I2C1, ENABLE);
27
28
while (I2C_GetFlagStatus(I2C1, I2C_FLAG_BUSY))
29
{
30
  //just wait until no longer busy
31
}
32
33
I2C_AcknowledgeConfig(I2C1, DISABLE);
34
35
I2C_GenerateSTART(I2C1, ENABLE);
36
while (!I2C_GetFlagStatus(I2C1, I2C_FLAG_SB))
37
{
38
  //wait for generation of start condition
39
}
40
41
I2C_Send7bitAddress(I2C1, CODEC_I2C_ADDRESS, I2C_Direction_Receiver);
42
while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED))
43
{
44
  //wait for end of address transmission
45
}
46
47
while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_RECEIVED))
48
{
49
  //wait until byte arrived
50
}
51
receivedByte = I2C_ReceiveData(I2C1);
52
53
I2C_GenerateSTOP(I2C1, ENABLE);
54
55
return receivedByte;
56
//\

send_codec_ctrl
1
uint8_t bytesSent=0;
2
3
while (I2C_GetFlagStatus(I2C1, I2C_FLAG_BUSY))
4
{
5
  //just wait until no longer busy
6
}
7
8
I2C_GenerateSTART(I2C1, ENABLE);
9
while (!I2C_GetFlagStatus(I2C1, I2C_FLAG_SB))
10
{
11
  //wait for generation of start condition
12
}
13
I2C_Send7bitAddress(I2C1, CODEC_I2C_ADDRESS, I2C_Direction_Transmitter);
14
while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED))
15
{
16
  //wait for end of address transmission
17
}
18
while (bytesSent < numBytes)
19
{
20
  I2C_SendData(I2C1, controlBytes[bytesSent]);
21
  bytesSent++;
22
  while (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTING))
23
  {
24
    //wait for transmission of byte
25
  }
26
}
27
while(!I2C_GetFlagStatus(I2C1, I2C_FLAG_BTF))
28
{
29
    //wait until it's finished sending before creating STOP
30
}
31
I2C_GenerateSTOP(I2C1, ENABLE)

i2s.init
1
#define SpiPeriphNr  3
2
#define SpiAf      GPIO_AF_SPI3
3
#define SpiMisoPort  PORTC
4
#define SpiMisoPinNr 7
5
#define SpiMosiPort  PORTC
6
#define SpiMosiPinNr 12
7
#define SpiSckPort   PORTC
8
#define SpiSckPinNr  10
9
10
////// SPI Clock
11
Rcc rcc;
12
#if SpiPeriphNr == 1
13
  #define SpiPeriph SPI1
14
  rcc.apb2PeriphClockCmd( RCC_APB2Periph_SPI1, ENABLE);
15
#elif SpiPeriphNr == 2
16
  #define SpiPeriph SPI2
17
  rcc.apb1PeriphClockCmd( RCC_APB1Periph_SPI2, ENABLE);
18
#elif SpiPeriphNr == 3
19
  #define SpiPeriph SPI3
20
  rcc.apb1PeriphClockCmd( RCC_APB1Periph_SPI3, ENABLE);
21
#else
22
  #error Keine SPI-Konfiguration
23
#endif
24
25
////// MISO C7
26
{
27
  rcc.ahb1PeriphClockCmd( (1<<(((uint32_t)SpiMisoPort-AHB1PERIPH_BASE)/0x400)) ,ENABLE);
28
  
29
  Gpio port;
30
  port.initStruct.GPIO_Pin   =  (1<<SpiMisoPinNr);
31
  port.initStruct.GPIO_Mode  = GPIO_Mode_AF;
32
  port.initStruct.GPIO_OType   = GPIO_OType_PP;
33
  port.initStruct.GPIO_PuPd   = GPIO_PuPd_NOPULL;        
34
  port.initStruct.GPIO_Speed = GPIO_Speed_50MHz;
35
  port.init(SpiMisoPort);
36
  port.pinAfConfig(SpiMisoPinNr, SpiAf);
37
}
38
39
////// MOSI C12
40
{
41
  rcc.ahb1PeriphClockCmd( (1<<(((uint32_t)SpiMosiPort-AHB1PERIPH_BASE)/0x400)) ,ENABLE);
42
  
43
  Gpio port;
44
  port.initStruct.GPIO_Pin   =  (1<<SpiMosiPinNr);
45
  port.initStruct.GPIO_Mode  = GPIO_Mode_AF;
46
  port.initStruct.GPIO_OType   = GPIO_OType_PP;
47
  port.initStruct.GPIO_PuPd   = GPIO_PuPd_NOPULL;        
48
  port.initStruct.GPIO_Speed = GPIO_Speed_50MHz;
49
  port.init(SpiMosiPort);
50
  port.pinAfConfig(SpiMosiPinNr, SpiAf);
51
}
52
53
////// SCK C10
54
{
55
  rcc.ahb1PeriphClockCmd( (1<<(((uint32_t)SpiSckPort-AHB1PERIPH_BASE)/0x400)) ,ENABLE);
56
  
57
  Gpio port;
58
  port.initStruct.GPIO_Pin   =  (1<<SpiSckPinNr);
59
  port.initStruct.GPIO_Mode  = GPIO_Mode_AF;
60
  port.initStruct.GPIO_OType   = GPIO_OType_PP;
61
  port.initStruct.GPIO_PuPd   = GPIO_PuPd_NOPULL;        
62
  port.initStruct.GPIO_Speed = GPIO_Speed_50MHz;
63
  port.init(SpiSckPort);
64
  port.pinAfConfig(SpiSckPinNr, SpiAf);
65
}
66
67
////// WS  A4
68
{
69
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
70
  // rcc.AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOA ,ENABLE);
71
  
72
  Gpio port;
73
  port.initStruct.GPIO_Pin   = GPIO_Pin_4;
74
  port.initStruct.GPIO_Mode  = GPIO_Mode_AF;
75
  port.initStruct.GPIO_OType   = GPIO_OType_PP;
76
  port.initStruct.GPIO_PuPd   = GPIO_PuPd_NOPULL;        
77
  port.initStruct.GPIO_Speed  = GPIO_Speed_50MHz;
78
  port.init(PORTA);
79
  port.pinAfConfig(GPIO_Pin_4, SpiAf);
80
}
81
// Clock an 
82
   
83
84
RCC_PLLI2SCmd(ENABLE);
85
I2S_InitTypeDef I2S_InitType;
86
87
I2S_InitType.I2S_Mode     = I2S_Mode_MasterTx;
88
I2S_InitType.I2S_AudioFreq  = I2S_AudioFreq_48k;
89
I2S_InitType.I2S_MCLKOutput = I2S_MCLKOutput_Enable;
90
I2S_InitType.I2S_DataFormat = I2S_DataFormat_16b;
91
I2S_InitType.I2S_Standard   = I2S_Standard_Phillips;
92
I2S_InitType.I2S_CPOL    = I2S_CPOL_Low;
93
 
94
I2S_Init(SPI3, &I2S_InitType);
95
 
96
I2S_Cmd(SPI3, ENABLE);

i2s.Datasend
1
if(SPI_I2S_GetFlagStatus(SPI3,SPI_I2S_FLAG_TXE))
2
{  
3
  //waitMs(Wartezeit);
4
    data = (uint16_t) data;
5
    SPI_I2S_SendData(SPI3, data);
6
    
7
}
8
else
9
  app.led1.toggle();

von Cel (Gast)


Lesenswert?

Push.

von Tobi D. (fanti)


Lesenswert?

Bei deinem Problem kann ich dir leider nicht helfen,
aber ich habe mich bei meinem Board ebenfalls an die Anleitung von 
"mind-dump" gehalten bzw. den Code von dieser Seite verwendet.
Bei mir läuft der CS43L22 sofort los.

was ich komisch finde:
du sendest zusätzlich zu den 16-bit Daten, nochmal kurz darauf andere 
Daten.
Du solltest pro "Flag"-Anzeige nur ein Datenpaket senden.
mach lieber sowas wie:
if(zähler==0)
daten1 senden
zähler=1
if(zähler==1)
daten2 senden
zähler=0

von Cel (Gast)


Lesenswert?

Ich sende wesentlich langsamer Daten, als in deiner Variante.
Mittlerweile habe ich das Problem gelöst, ich habe vergessen vor dem 
Initialisieren des DAC's seinen Reset auf Low zu ziehen. 
Zwischenzeitlich hatte ich das Problem, dass es immer wieder Aussetzer 
beim senden von Daten gab. Kurioserweise geschieht das ohne die 
LED-Klasse nicht mehr!

Jetzt werde ich probieren eine Wavedatei abzuspielen.

von Cel (Gast)


Lesenswert?

Ich bräuchte nochmal ein wenig Hilfe! Ich habe das Filesystem(FatFs) 
angebunden und das Abspielen, der Sawwave klappt auch problemlos. Nun 
stellt sich mir die Frage: Wie soll ich die Wavedatei auslesen? Bringt 
das Filesystem eine Funktion mit, mit welcher ich die Datei Stück für 
Stück auslesen und abspielen kann?

Vielen Dank und Freundliche Grüße!

von Falk B. (falk)


Lesenswert?

@ Cel (Gast)

>stellt sich mir die Frage: Wie soll ich die Wavedatei auslesen?

Stückwese und über einen Software-FIFO.

>Bringt
>das Filesystem eine Funktion mit, mit welcher ich die Datei Stück für
>Stück auslesen

Ja. das normale fread() oder wie auch immer sie heißt.

>und abspielen kann?

Da muss man selber einiges tun.

von Cel (Gast)


Lesenswert?

Okay, Danke für die Hilfe, ich habe bisher folgendes:
1
File fa;
2
3
if(fa.open("/test.wav", true, false))
4
{ 
5
  size = fa.getSize();
6
  
7
  do{
8
    fa.read((uint8_t*)&sample, 2);
9
    i++;
10
  }while(i < 22);
11
12
  // Header überspringen
13
14
  i=0;
15
  
16
  do{
17
    fa.read(((uint8_t*)&sample),2);
18
    i2s.Datasend(sample);
19
    i++;
20
  }while(i <= size);
21
  
22
  fa.close();
23
}

Leider funktioniert das bisher noch nicht! Der Grund dafür ist mir nicht 
ganz klar.
Habe ich einen Denkfehler? Ich überspringe die ersten 44 Bytes des 
Headers, folgend lese ich theoretisch die Daten der Wavedatei und gebe 
sie über den I2S aus, leider ist nichts auf dem Kopfhörer zu hören.

von Cel (Gast)


Lesenswert?

Hat keiner weitere Ideen oder Hinweise?

von PittyJ (Gast)


Lesenswert?

2 Möglichkeiten;
-- Lesen geht nicht richtig
-- I2S Senden geht nicht richtig.

Lass einfach mal das Lesen weg und sende eine synthetischen Ton.
z.B. einen Sinus, den du dir vorher in eine kleine Tabelle schreibst.
Dann kann du hören, ob zumindest das geht. Und dann etnsprechend weiter 
nach dem Fehler suchen.

Bei einen Read können immer Wartezeiten auftreten, falls wirklich mal 
ein neuer Block vom Device geholt werden muss.
Deshalb buffert man im Normalfall mehr, und hat 2 Threads: einen zum 
Lesen, einen zum Abspielen.

von Cel (Gast)


Lesenswert?

Danke PittyJ!
Wie schon oben geschrieben, lässt sich ein 'synthetischer Ton' ausgeben. 
Auch das Lesen und schreiben funktioniert auf die SD - Karte.

Du hattest aber Recht mit den Wartezeiten, ich habe bei meinen Routinen 
jetzt  alle 'Debug' - Ausgaben u.ä. raus geworfen. Jetzt höre ich 
zumindest wieder etwas( Rauschen und Knacken) und die Dauer stimmt über 
den Daumen gepeilt, auch mit der Dauer der Audiodatei überein.

Du hattest also auch damit Recht, dass ich zwei Routinen brauch. Eine 
zum lesen und in einen Buffer schreiben - die Zweite für das Lesen aus 
dem Buffer und den I2S senden.

von Cel (Gast)


Lesenswert?

Ich habe die Routinen jetzt geschrieben. Über die Effizienz und 
Schönheit lässt sich sicher streiten.

Aber, ich muss diese ja Quasi'-parallel' ab arbeiten? Hat dazu jemand 
eine schöne Idee?
1
// Routine um zu schauen ob Ende der Datei erreicht ist
2
a=10000; 
3
i=0;
4
5
if(size > (sizeof(buffer1))) // sizeofbuffer= 10.000, Buffer mit 10.000 Werten befüllen, wenn mehr als 10.000 Werte da sind
6
 {
7
   size= size - a; // size - 10.000
8
 }  
9
else
10
 {
11
   a=size;
12
   EOFFlag=false;
13
 }
14
 
15
16
// buffer1[10k] - fuellen
17
if(EObuffer)
18
{
19
  for( i = 0 ; i < a ; i++)
20
    {
21
        fa.read((uint8_t*)&buffer1[i], 2);
22
    }
23
}  
24
if(EOFFlag == false)
25
{
26
  EObuffer = false;
27
}
28
29
30
// buffer2[10k] - fuellen
31
32
if(EObuffer)
33
{
34
  for( i = 0; i < a ; i++)
35
  {
36
      fa.read((uint8_t*)&buffer2[i], 2);
37
  }
38
}  
39
if(EOFFlag == false)
40
{
41
  EObuffer = false;
42
}
43
44
45
// buffer1 - lesen
46
if(EOplay)
47
{
48
  for( i = 0 ; i < a ; i++)
49
  {
50
   i2s.Datasend(buffer1[i]);
51
  }
52
}  
53
if(EObuffer == false)
54
{
55
  EOplay = false;
56
}
57
58
// buffer2 - lesen
59
if(EOplay)
60
{
61
  for( i = 0; i < a; i++)
62
  {
63
   i2s.Datasend(buffer2[i]);
64
  }
65
}  
66
if(EObuffer == false)
67
{
68
  EOplay = false;
69
}

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.