STM32 - nie działa I2S ?

Jun 20, 2009 0 Replies

Witajcie.



Mam sobie STM32F103VCT6. Zachciało mi się zrobić układ, w którym interfejs audio mikrokontrolera będzie pracował w trybie: slave transmitter, packet frame 32-bit, data format 16-bit (extended) lub 24-bit, right justified.



Niestety paczki danych wyjściowych wpadają losowo w stosunku do sygnału word select za każdym uruchomieniem programu lub chwilowego zaniku bitclock. Bity danych trzymają się jedynie zegara. Wygląda to tak, jakby interfejs SPI/I2S olewał sygnał WS tylko odliczał sobie takty zegara (po 32 cykle). Tak samo jest dla SPI2 jak i SPI3. Master transmitter działa jak powinien.



Czy ktoś przerabiał ten temat? Nie wiem, czy coś źle konfiguruję, czy procek zwalony, a może kompilator. Opierałem się o przykłady z ST.



Oto kawałki konfigurujące sam interfejs. Jeśli ktoś chce mogę podesłać cały kod testowy. Używam pakietu Raisonance v.7.



main() ... GPIO_Configuration(); /* INICJALIZACJA I2S */ I2S_InitStructure.I2S_Standard = I2S_Standard_LSB; // right justified I2S_InitStructure.I2S_DataFormat = I2S_DataFormat_16bextended; //16-bit in 32-bit packets I2S_InitStructure.I2S_MCLKOutput = I2S_MCLKOutput_Disable; I2S_InitStructure.I2S_AudioFreq = I2S_AudioFreq_48k; I2S_InitStructure.I2S_CPOL = I2S_CPOL_Low;



/* I2S2 configuration */ I2S_InitStructure.I2S_Mode = I2S_Mode_MasterTx; I2S_Init(SPI2, &I2S_InitStructure);



/* I2S3 configuration */ I2S_InitStructure.I2S_Mode = I2S_Mode_SlaveTx; I2S_Init(SPI3, &I2S_InitStructure);



/* Enable the I2S2 RxNE interrupt */ SPI_I2S_ITConfig(SPI2, SPI_I2S_IT_TXE, ENABLE);



/* Enable the I2S3 RxNE interrupt */ SPI_I2S_ITConfig(SPI3, SPI_I2S_IT_TXE, ENABLE);



/* Enable the I2S2 */ I2S_Cmd(SPI2, ENABLE);



/* Enable the I2S3 */ I2S_Cmd(SPI3, ENABLE);



while(1);



void GPIO_Configuration(void) ... /* INICJALIZACJA GPIO */ /* Disable the JTAG interface and enable the SWJ interface */ GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);



/* Configure SPI2 pins: CK, WS and SD ---------------------------------*/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_15; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOB, &GPIO_InitStructure);



/* Configure SPI3 pins: CK and SD ------------------------------------*/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5; GPIO_Init(GPIOB, &GPIO_InitStructure);



GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; // CK - wejście na 'siłę' GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; GPIO_Init(GPIOB, &GPIO_InitStructure);



/* Configure SPI3 pins: WS -------------------------------------------*/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15; // WS - wejście na 'siłę' GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; GPIO_Init(GPIOA, &GPIO_InitStructure); ....



Michał



Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required