ΣSigmaStudio Ask AI Русский Log in

ADAU1701 SigmaStudioFW.h

SigmaDSP & SigmaStudio EEtwidget Mar 12, 2014 00:00 3 replies Original on forum ↗
Subscribe
EEtwidget Question
Mar 12, 2014 00:00

Hello, maybe you can help me out. I am new to the world of DSP and have run into a road block with the SigmaStudioFW.h macro thing.

ucontroller: mbed LPC1768

compiler: mbed online IDE

Analog Devices: EVAL-ADAU1701MINIB7 with USBi

I created a simple program in SigmaStudio:

I generated the files:

Design_1_IC_1.h

Design_1_IC_1_PARAM.h

Design_1_IC_1_REG.h

I copied the file:

SigmaStudioFW.h

And placed everything into a library for my ucontroller

I worked off this example and found the SigmaStudioFW.h they used:

/* * File: SigmaStudioFW.h * * Description: SigmaStudio System Framwork macro definitions. These * macros should be implemented for your system's software. * * This software is distributed in the hope that it will be useful, * but is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * This software may only be used to program products purchased from * Analog Devices for incorporation by you into audio products that * are intended for resale to audio product end users. This software * may not be distributed whole or in any part to third parties. * * Copyright 2008 Analog Devices, Inc. All rights reserved. */ #ifndef __SIGMASTUDIOFW_H__ #define __SIGMASTUDIOFW_H__ /* * TODO: Update for your system's data type */ typedef unsigned short ADI_DATA_U16; typedef unsigned char ADI_REG_TYPE; extern vu16 Tx_Idx, Rx_Idx; extern vu16 NextBufferEnd, ThisBufferSize; extern u8 I2C1_Buffer_Tx[]; #define Address_Length 2 void SIGMA_WRITE_REGISTER_BLOCK(int devAddress, int address, int length, ADI_REG_TYPE *pData); void SIGMA_WRITE_DELAY(int devAddress, int length, ADI_REG_TYPE *pData ); /* * Parameter data format */ #define SIGMASTUDIOTYPE_FIXPOINT 0 #define SIGMASTUDIOTYPE_INTEGER 1 /* * Write to a single Device register */ #define SIGMA_WRITE_REGISTER( devAddress, address, dataLength, data ) {/*TODO: implement macro or define as function*/} /* * TODO: CUSTOM MACRO IMPLEMENTATION * Write to multiple Device registers */ void SIGMA_WRITE_REGISTER_BLOCK(int devAddress, int address, int length, ADI_REG_TYPE *pData ) { int ii = 0; int zz = 0; Tx_Idx = 0; /*----- Transmission Phase -----*/ ThisBufferSize = Address_Length + length; I2C1_Buffer_Tx[0] = (address & 0xFF00)>>8; I2C1_Buffer_Tx[1] = address & 0x00FF; for(zz=0;zz<length;zz++) { I2C1_Buffer_Tx [zz + Address_Length] = pData[zz]; } Tx_Idx = 0; for(ii =0;ii < ThisBufferSize;ii++) { NextBufferEnd = ThisBufferSize;//I2C1_numbytes[ii]; if(ii == 0) I2C_GenerateSTART(I2C1, ENABLE); /* Send data */ while(Tx_Idx < NextBufferEnd) { } } } void SIGMA_WRITE_DELAY(int devAddress, int length, ADI_REG_TYPE *pData ) { // int cnt=0; int nCount=0; //int data_length = length - Address_Length; // ADI_REG_TYPE data[4]={0x05, 0xF5, 0xE1, 0x00}; // for(cnt=0; cnt<data_length; cnt++) // { // nCount &= pData[cnt] >> (8*cnt); // } // for(cnt=0; cnt<4; cnt++) // { // nCount += data[cnt]; // nCount = nCount<<(8); // // } //nCount=0xFFFFFF; //nCount=0x15752A00; //5 secs approx //nCount=0x05F5E100; //5 secs approx nCount=0xFFFFF; for(; nCount != 0; nCount--); } /* * Read device registers */ #define SIGMA_READ_REGISTER( devAddress, address, length, pData ) {/*TODO: implement macro or define as function*/} /* * Set a register field's value */ #define SIGMA_SET_REGSITER_FIELD( regVal, fieldVal, fieldMask, fieldShift ) \ { (regVal) = (((regVal) & (~(fieldMask))) | (((fieldVal) << (fieldShift)) && (fieldMask))) } /* * Get the value of a register field */ #define SIGMA_GET_REGSITER_FIELD( regVal, fieldMask, fieldShift ) \ { ((regVal) & (fieldMask)) >> (fieldShift) } /* * Convert a floating-point value to SigmaDSP (5.23) fixed point format * This optional macro is intended for systems having special implementation * requirements (for example: limited memory size or endianness) */ #define SIGMASTUDIOTYPE_FIXPOINT_CONVERT( _value ) {/*TODO: IMPLEMENT MACRO*/} /* * Convert integer data to system compatible format * This optional macro is intended for systems having special implementation * requirements (for example: limited memory size or endianness) */ #define SIGMASTUDIOTYPE_INTEGER_CONVERT( _value ) {/*TODO: IMPLEMENT MACRO*/} #endif

I changed parts of the code to work with the mbed (although I don't think its working)

#ifndef __SIGMASTUDIOFW_H__ #define __SIGMASTUDIOFW_H__ #include "mbed.h" #define I2C_ADDR_ADAU1701 0x68 typedef unsigned short ADI_DATA_U16; typedef unsigned char ADI_REG_TYPE; extern uint16_t Tx_Idx = 0; extern uint16_t Rx_Idx = 0; extern uint16_t NextBufferEnd = 0; extern uint16_t ThisBufferSize = 0; extern uint8_t I2C1_Buffer_Tx[] = {0x00}; #define Address_Length 2 void SIGMA_WRITE_REGISTER_BLOCK(int devAddress, int address, int length, ADI_REG_TYPE *pData); void SIGMA_WRITE_DELAY(int devAddress, int length, ADI_REG_TYPE *pData ); I2C i2c(p28,p27); // sda, scl /* * Parameter data format */ #define SIGMASTUDIOTYPE_FIXPOINT 0 #define SIGMASTUDIOTYPE_INTEGER 1 /* * Write to a single Device register */ #define SIGMA_WRITE_REGISTER( devAddress, address, dataLength, data ) {/*TODO: implement macro or define as function*/} /* * TODO: CUSTOM MACRO IMPLEMENTATION * Write to multiple Device registers */ void SIGMA_WRITE_REGISTER_BLOCK(int devAddress, int address, int length, ADI_REG_TYPE *pData ) { int ii = 0; int zz = 0; Tx_Idx = 0; /*----- Transmission Phase -----*/ ThisBufferSize = Address_Length + length; I2C1_Buffer_Tx[0] = (address & 0xFF00)>>8; I2C1_Buffer_Tx[1] = address & 0x00FF; for(zz=0;zz<length;zz++) { I2C1_Buffer_Tx [zz + Address_Length] = pData[zz]; } Tx_Idx = 0; for(ii =0;ii < ThisBufferSize;ii++) { NextBufferEnd = ThisBufferSize;//I2C1_numbytes[ii]; if(ii == 0) i2c.start(); /* Send data */ while(Tx_Idx < NextBufferEnd) { } } }

My main is very simple

#include "mbed.h" #include "Design_1_IC_1_PARAM.h" #include "Design_1_IC_1_REG.h" #include "Design_1_IC_1.h" #include "SigmaStudioFW.h" int main() { default_download_IC_1(); }

Seems like I should be sending I2C data in this part of the code but in the example its left blank...

if(ii == 0) I2C_GenerateSTART(I2C1, ENABLE); /* send data */ while(TX_IDX < NextBufferEnd) { //send I2C data here? }

What am I doing wrong?

Audio Signal Processors

SigmaDSP Audio Processors

adau1701

3704.c19643ed22ae14f6ec04249b76964df5.png
3704.c19643ed22ae14f6ec04249b76964df5.png
3704.c19643ed22ae14f6ec04249b76964df5.png-443x161.png
3704.c19643ed22ae14f6ec04249b76964df5.png-443x161.png
4401.52b506b553ad5bc660285d69bc124199.png
4401.52b506b553ad5bc660285d69bc124199.png
4401.52b506b553ad5bc660285d69bc124199.png-205x124.png
4401.52b506b553ad5bc660285d69bc124199.png-205x124.png
Yagami Reply
Mar 15, 2014 00:00

Hi EEtwidget,

I'm not much of a microcontroller expert, but instead of diving right into the code, maybe we could take a look at the actual I2C signals on your board when you try to execute a write. That will be helpful for debugging where the problem might lie in your code. For example, we could easily look at the start of a write and confirm that the data and clock lines have the correct phase and timing. If that's correct, we can move on and start counting bits and confirm that the device address byte is correct. After that, we can move on to the subaddress bytes and the data bytes. By actually seeing the signals, it might become apparent what is going wrong in the code, and then we can look back to the code to correct the bug.

EEtwidget Reply
Mar 15, 2014 00:00

Hey Yagami;

I will try to post some I2C data tomorrow. However, I am able to load the DSP enough to start up a simple program. [500hz sine wave generator, mute switch, DAC3 output] I also entered debug code in the default_driver() function. It prints a tack [-] to the terminal every time default_driver() calls SIGMA_WRITE_REGISTER_BLOCK(...) actually, it prints the tack after the function completes. I only see one tack and I verified a full packet of I2C data. At a glance only but I see the start bit.. lots of data ... and the stop bit.

Something in my SIGMA_WRITE_REGISTER_BLOCK(...) is not resetting, thus stopping the function from running again. I was kind of blindly copying the example and didn't put much thought into it. I have shortened my code and just now I added a spot to clear the variable. Ill check it tomorrow.

EZAdministrator Reply
Aug 2, 2018 00:00

This question has been assumed as answered either offline via email or with a multi-part answer. This question has now been closed out. If you have an inquiry related to this topic please post a new question in the applicable product forum.

Thank you,
EZ Admin