Clock domain for I2S 48KHz Clock
 
Yellow is I2S Clock(16bit), Green is 48Khz WS waveform.
 
 
 
unsigned char i=0;
int main(void)
{
       /* Initializes MCU, drivers and middleware */
       atmel_start_init();
       /* enable USART module */
       usart_sync_enable(&USART_0);
       i2s_c_sync_enable(&I2S_0);
       /* Configure DMA channels */
       //Configure_Channel_rx();
       Configure_Channel_tx();
       Configure_Channel_i2s_tx();
       
       //_dma_enable_transaction(CONF_USART_RECEIVE_DMA_CHANNEL, false);
       /* Replace with your application code */
       
       
       /* There will be waveform after init. */
       
       /* Breakpoint and Step over to see wave changes. */
       //i2s_c_sync_set_ws_length(&I2S_0, I2SC_MR_DATALENGTH_32_BITS_Val);
       //i2s_c_sync_set_sck_div(&I2S_0, 16);
              
       string[0] = 'a';
       string[1] = 'b';
       string[2] = 'c';
       string[3] = 'd';
       string[4] = 'e';
       string[5] = 'f';
       string[6] = '0';
       string[7] = '1';
       
       i2s_data[0] = 0xAA;
       i2s_data[1] = 0xAA;
       i2s_data[2] = 0xAA;
       i2s_data[3] = 0xAA;
       i2s_data[4] = 0xAA;
       i2s_data[5] = 0xAA;
       i2s_data[6] = 0xAA;
       i2s_data[7] = 0xAA;
       //I2S_0_example();
       i2s_c_sync_set_ws_length(&I2S_0, I2SC_MR_DATALENGTH_16_BITS_Val);
       i2s_c_sync_set_sck_div(&I2S_0, 16);      
       //i2s_c_sync_write_thr(&I2S_0,0x55555555);
       gpio_toggle_pin_level(LED0);
       
       while (1) {
              //if (transferComplete) {
                     ///* reset source and destination address before re-enabling the channel */
                     //_dma_set_source_address(CONF_USART_RECEIVE_DMA_CHANNEL,
                                             //(uint32_t) & (((Usart *)(USART_0.device.hw))->US_RHR));
                     //_dma_set_destination_address(CONF_USART_RECEIVE_DMA_CHANNEL, (uint32_t *)string);
                     //_dma_set_data_amount(CONF_USART_RECEIVE_DMA_CHANNEL, (uint32_t)BUFFER_LEN);
//
                     //_dma_enable_transaction(CONF_USART_RECEIVE_DMA_CHANNEL, false);
                     //transferComplete = 0;
              //}
              //if (receiveComplete) {
                     /* reset source and destination address before re-enabling the channel */
                     _dma_set_source_address(CONF_USART_TRANSMIT_DMA_CHANNEL, (uint32_t *)string);
                     _dma_set_destination_address(CONF_USART_TRANSMIT_DMA_CHANNEL,
                                                  (uint32_t) & (((Usart *)(USART_0.device.hw))->US_THR));
                     _dma_set_data_amount(CONF_USART_TRANSMIT_DMA_CHANNEL, (uint32_t)BUFFER_LEN);
                     _dma_enable_transaction(CONF_USART_TRANSMIT_DMA_CHANNEL, false);
                     
                     
                     
                     _dma_set_source_address(CONF_I2S_DMA_CHANNEL, (uint32_t *)i2s_data);
                     //_dma_set_destination_address(CONF_I2S_DMA_CHANNEL,(void *)REG_I2SC0_THR);
                     //_dma_set_destination_address(CONF_I2S_DMA_CHANNEL,0x4008C024);
                     _dma_set_destination_address(CONF_I2S_DMA_CHANNEL,(void *const)&REG_I2SC0_THR);
                     //(uint32_t) & (((Usart *)(I2S_0.device.hw))->I2SC_THR));
                     _dma_set_data_amount(CONF_I2S_DMA_CHANNEL, (uint32_t)BUFFER_LEN);
                     _dma_enable_transaction(CONF_I2S_DMA_CHANNEL, false);
                     
                     delay_ms(100);
                     gpio_toggle_pin_level(LED0);
       }
}
 
 
 
Posted by KennyShin
,