Mikrocontroller und Digitale Elektronik
›
Thread
STM32F107 I2S3 Problem
F
Franz
Gast
28.05.2016 22:52
#4594281
Hi Leute,
ich bekomme beim I2S3 nur den Masterclock Output mit 2MHz zum zappen.
Alles andere schweigt so vor sich hin.
Was mir aufgefallen ist, das der DR Register von SPI3 mit der Funktion
"SPI_I2S_SendData" nicht gefüllt wird (festgestellt mit Debugger im
CooCox).
Im Anhang habe ich auch die GPIO Übersicht beigefügt.
Bin für jede Hilfe bei der Problembehebung dankbar
Hier die I2S3 Inititialisierung: 1 void I2S3_init ()
2 {
3 GPIO_InitTypeDef GPIO_InitStructure ;
4 I2S_InitTypeDef I2S_InitStructure ;
5
6
7 RCC_APB2PeriphClockCmd ( RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOA , ENABLE );
8 RCC_APB1PeriphClockCmd ( RCC_APB1Periph_SPI3 , ENABLE );
9
10 GPIO_InitStructure . GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_10 | GPIO_Pin_12 ;
11 GPIO_InitStructure . GPIO_Speed = GPIO_Speed_50MHz ;
12 GPIO_InitStructure . GPIO_Mode = GPIO_Mode_AF_PP ;
13 GPIO_Init ( GPIOC , & GPIO_InitStructure );
14 //GPIO_PinRemapConfig(GPIO_Remap_SPI3, ENABLE);
15
16 GPIO_InitStructure . GPIO_Pin = GPIO_Pin_4 ;
17 GPIO_InitStructure . GPIO_Mode = GPIO_Mode_AF_PP ;
18 GPIO_Init ( GPIOA , & GPIO_InitStructure );
19
20 I2S_InitStructure . I2S_Standard = I2S_Standard_Phillips ;
21 I2S_InitStructure . I2S_DataFormat = I2S_DataFormat_16b ;
22 I2S_InitStructure . I2S_MCLKOutput = I2S_MCLKOutput_Enable ;
23 I2S_InitStructure . I2S_AudioFreq = I2S_AudioFreq_8k ;
24 I2S_InitStructure . I2S_CPOL = I2S_CPOL_Low ;
25
26 I2S_InitStructure . I2S_Mode = I2S_Mode_MasterTx ;
27 I2S_Init ( SPI3 , & I2S_InitStructure );
28
29
30 I2S_Cmd ( SPI3 , ENABLE );
31
32 }
Hier eine Folge zum abspielen 1 uint16_t SOUND [] = { 0x0102 , 0x0304 , 0x0506 , 0x0708 , 0x090A , 0x0B0C ,
2 0x0D0E , 0x0F10 , 0x1112 , 0x1314 , 0x1516 , 0x1718 ,
3 0x191A , 0x1B1C , 0x1D1E , 0x1F20 , 0x2122 , 0x2324 ,
4 0x2526 , 0x2728 , 0x292A , 0x2B2C , 0x2D2E , 0x2F30 ,
5 0x3132 , 0x3334 , 0x3536 , 0x3738 , 0x393A , 0x3B3C ,
6 0x3D3E , 0x3F40 };
Hier wie die Daten an das SPI3 übergeben werden sollen
1 while ( 1 )
2 {
3 i ++ ;
4 while ( SPI_I2S_GetFlagStatus ( SPI3 , SPI_I2S_FLAG_TXE ) == RESET );
5 SPI_I2S_SendData ( SPI3 , SOUND [ i ++ ]);
6 if ( i == sizeof ( SOUND )) i = 0 ;
7
8 }
So werden die Clocks konfiguriert 1 SystemInit ();
2 RCC_I2S3CLKConfig ( RCC_I2S3CLKSource_SYSCLK );
3 RCC_PLL3Cmd ( ENABLE );
4 while ( RCC_GetFlagStatus ( RCC_FLAG_PLL3RDY ) == RESET ){}
5 SystemCoreClockUpdate ();
Danke im voraus!
Gruß,
Franz
Versuch es mal mit 1 RCC_APB2PeriphClockCmd ( RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOA | RCC_APB2Periph_AFIO , ENABLE );
2 RCC_APB1PeriphClockCmd ( RCC_APB1Periph_SPI3 , ENABLE );
3
4 GPIO_InitStructure . GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_10 | GPIO_Pin_12 ;
5 GPIO_InitStructure . GPIO_Speed = GPIO_Speed_50MHz ;
6 GPIO_InitStructure . GPIO_Mode = GPIO_Mode_AF_PP ;
7 GPIO_Init ( GPIOC , & GPIO_InitStructure );
8 GPIO_PinRemapConfig ( GPIO_Remap_SPI3 , ENABLE );
9
10 GPIO_InitStructure . GPIO_Pin = GPIO_Pin_4 ;
11 GPIO_InitStructure . GPIO_Mode = GPIO_Mode_AF_PP ;
12 GPIO_Init ( GPIOA , & GPIO_InitStructure );
Und iiiimmmer schön das DB lesen, dann klappt es schon ;-)
Antwort schreiben
Bitte melde dich an, um einen Beitrag zu schreiben.
Noch kein Account?
Die Registrierung ist kostenlos und dauert nur eine Minute.
Jetzt registrieren