Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years, 9 months ago.
Nucleo F401RE I2S Full Duplex
HI,
I am attempting to get a 401 to talk to a TLC320 in full duplex however I cannot get I2Sext to either send or transmit data.
Any help gratefully received.
Tim
The register settings that I have are: SPI2 Registers CR1: 00000000 CR2: 00000000 SR: 00000002 I2SCFGR: 00000900 I2SPR: 00000002
SPI2ext Registers CR1: 00000000 CR2: 00000000 SR: 00000002 I2SCFGR: 00000800 I2SPR: 00000002
GPIOA Registers AFR[0]: 00007700 AFR[1]: 00000000 MODER: a80004a0 PUPDR: 64000050
GPIOB Registers AFR[0]: 00000000 AFR[1]: 55550044 MODER: aa0a1280 PUPDR: 550f30c0
These are set up by:
void I2SInit () { unsigned int uiValue; GPIO_InitTypeDef GPIO_Init; I2S_InitTypeDef I2S_InitStructure;
turn on GPIOB peripheral clock RCC->AHB1ENR |= RCC_AHB1ENR_GPIOBEN; TODO remove next line RCC->AHB1ENR |= RCC_AHB1ENR_DMA1EN; RCC->APB1ENR |= RCC_APB1ENR_SPI2EN;
uiValue = GPIOB->AFR[1]; DBG(SerialPort, "Value: %08x", uiValue); Reset the the 4 MSB: uiValue &= 0x0000FFFF; Configure PB_12..15 to AF5: uiValue |= 0x55550000; DBG(SerialPort, "Value: %08x", uiValue); GPIOB->AFR[1] = uiValue;
configure PB_12..15 to AF uiValue = GPIOB->MODER; uiValue &= 0x00FFFFFF; uiValue |= 0xaa000000; DBG(SerialPort, "Value: %08x", uiValue); GPIOB->MODER = uiValue;
uiValue = GPIOB->OSPEEDR; Clear the bits: uiValue &= (GPIO_OSPEEDER_OSPEEDR12_0 | GPIO_OSPEEDER_OSPEEDR13_0 | GPIO_OSPEEDER_OSPEEDR14_0 | GPIO_OSPEEDER_OSPEEDR15_0); Set to pull up: uiValue |= GPIO_OSPEEDER_OSPEEDR12_0 | GPIO_OSPEEDER_OSPEEDR13_0 | GPIO_OSPEEDER_OSPEEDR14_0 | GPIO_OSPEEDER_OSPEEDR15_0; Set the register: GPIOB ->PUPDR = uiValue;
SPI2->I2SPR = 0x2; slave rx SPI2->I2SCFGR = SPI_I2SCFGR_I2SMOD | SPI_I2SCFGR_I2SCFG_0;
I2S2ext->I2SPR = 0x0002; slave tx I2S2ext->I2SCFGR = SPI_I2SCFGR_I2SMOD; }
The process is started by:
void I2SStart() { SPI2->I2SCFGR &= SPI_I2SCFGR_I2SE; I2S2ext->I2SCFGR &= SPI_I2SCFGR_I2SE; }
I have fixed this now. The problem was that PB_14 should be set to AF6 not AF5. See the Alternate function mapping table in the data sheet.
posted by Tim Frost 21 Feb 2017