LPC4337 I2S Synchronized Word Select Signals

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

LPC4337 I2S Synchronized Word Select Signals

362件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by kap5509 on Mon Aug 10 13:35:42 MST 2015
I am trying to setup the I2S peripheral on an LPC4337 device so that it will send and receive audio data in master mode. The problem I am having is that I would like to ensure that both the transmit and receive word select signals (left-right clock) are synchronized. Is there a special function or something that can handle that? Or is it just as simple as setting them up with the same dividers and source clocks? Below are the configuration functions. Thanks!

/* Configure I2S for Audio Format input */
Status Chip_I2S_TxConfig(LPC_I2S_T *pI2S, I2S_AUDIO_FORMAT_T *format)
{
uint32_t temp=0;
uint16_t xDiv, yDiv;
uint32_t N;

if (getClkDiv(pI2S, format, &xDiv, &yDiv, &N) == ERROR) {
    return ERROR;
}

//temp = pI2S->DAO & (~(I2S_DAO_WORDWIDTH_MASK | I2S_DAO_MONO | I2S_DAO_SLAVE | I2S_DAO_WS_HALFPERIOD_MASK));
/*if (format->WordWidth <= 8) {
    temp |= I2S_WORDWIDTH_8;
}
else if (format->WordWidth <= 16) {
    temp |= I2S_WORDWIDTH_16;
}
else {
    temp |= I2S_WORDWIDTH_32;
}*/
temp |= I2S_WORDWIDTH_32;
pI2S->DAO = I2S_DAO_WS_HALFPERIOD(format->WordWidth - 1);
temp |=I2S_STEREO;  //(format->ChannelNumber) == 1 ? I2S_MONO : I2S_STEREO;
temp |= I2S_MASTER_MODE;
temp |= I2S_DAO_WS_HALFPERIOD(format->WordWidth - 1);
pI2S->DAO = temp;
pI2S->TXMODE = I2S_TXMODE_CLKSEL(0);
pI2S->TXBITRATE = N-1;
pI2S->TXRATE = yDiv | (xDiv << 8);
return SUCCESS;
}

/* Configure I2S for Audio Format input */
Status Chip_I2S_RxConfig(LPC_I2S_T *pI2S, I2S_AUDIO_FORMAT_T *format)
{
uint32_t temp;
uint16_t xDiv, yDiv;
uint32_t N;

if (getClkDiv(pI2S, format, &xDiv, &yDiv, &N) == ERROR) {
    return ERROR;
}
temp = pI2S->DAI & (~(I2S_DAI_WORDWIDTH_MASK | I2S_DAI_MONO | I2S_DAI_SLAVE | I2S_DAI_WS_HALFPERIOD_MASK));
if (format->WordWidth <= 8) {
    temp |= I2S_WORDWIDTH_8;
}
else if (format->WordWidth <= 16) {
    temp |= I2S_WORDWIDTH_16;
}
else {
    temp |= I2S_WORDWIDTH_32;
}

temp |= (format->ChannelNumber) == 1 ? I2S_MONO : I2S_STEREO;
temp |= I2S_MASTER_MODE;
temp |= I2S_DAI_WS_HALFPERIOD(format->WordWidth - 1);
pI2S->DAI = temp;
pI2S->RXMODE = I2S_RXMODE_CLKSEL(0);
pI2S->RXBITRATE = N - 1;
pI2S->RXRATE = yDiv | (xDiv << 8);
return SUCCESS;
}
ラベル(1)
0 件の賞賛
返信
0 返答(返信)