This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
JP1 to JP8 I’ve kept inside position.
JP9 and JP11 are installed and JP13 isn’t installed.
AVDD = +15V.
AVSS is connected to ground.
DVDD is powered through USB-DIG.Outputs at channel for Input FFFF are,
Ch1 – 7.471 (4 - 20 mA)
Ch2 – 7.33V (0 -10V)
Ch3 – 3.903V (0 - 5V)
Ch4 – 7.15 (0-20 mA)
Naveen,
When the output of the DAC8775 isn't working, generally it's because of a missed configuration like the Buck-boost hasn't been powered up, or that the internal reference hasn't been enabled. I just powered up an EVM and you can copy my steps to use the device. Below is a picture of my setup. I think all of the jumpers are at default, but you can take a quick look.
First, I power up the device using TP18 and a ground test point (I have clip lead cables, and it's easier than getting two wires to screw into the terminals. I then run a RESET with the EVM GUI using the RESET button at the top center of the GUI. I first check the buck-boost converter by looking at the VPOS_IN_A and VNEG_IN_A. These voltages should be roughly TP1: +3.4V, TP2: +0.14V, and the EVM should be drawing about 4mA of current.
At the upper right side of the GUI, I then set All Buck-Boost to be All Enabled. This sets TP1: +4.1V, TP2: -5.6V. At the upper left side of the GUI, I set Reference Out to be Enabled. I think you can use TP17 at the center of the board to measure the reference. It should be 5.0V.
Then I enable the DAC output A. The DAC is in 0-5V output mode as default on the GUI. The output of channel A is measured at TP31. By enabling the DAC, you should just be at 0000h, and the output should be 0V. I then set the DAC code to 1000h just to see the output and I see the voltage go to 0.312V.
Then you can test the current output. First I set jumper J19 to shunt. This connects a load of 249Ω to VOUTA. Using the Mode for DAC Output A, I can set the output range to 4-20mA. This does set the DAC Data back to 0000h (even thought it doesn't report it and it still says 1000h). With the 249Ω load in 4-20mA range, I measure the voltage output at TP31 to be 0.986V. Again, this is with DAC data set to 0000h. Just to be sure I can re-write DAC data to be 1000h and the output jumps up to about 1.25V.
I would note that there is a parallel resistive load in the device that can be shut off. In the upper left side of the GUI is the Power-off Condition setting. It sets a parallel VOUT load of 30kΩ. Because the VOUT and IOUT are connected together on each of the channels, the output sees this extra load. You can set it be High-Z for both with that pull-down setting to remove the load.
Joseph Wu
Hi Joseph,
Thanks for your reply. I have following doubts, In the above answer "I set jumper J19 to shunt" means to connect J19 using jumpers right? In your image what does the highlighted connection means?
Also Vout/Iout works for 3 channels and when I configure fourth channel and write value to the fourth channel I see there is a voltage drop and current drop in all four channel
With regards,
Naveen
I powered on checked input voltage it was correct, I then did reset checked buck boosters voltage it was correct, then I enabled Buck booster and checked voltage on TP1 - TP8 it was correct as mentioned above
Then I configured channels as follows
Ch1 – 4 - 20 mA
Ch2 – 0 -10V
Ch3 – 0 - 5V
Ch4 – 0-20 mA
After enabling first three channels the voltage levels are,
Input voltage AVDD is +15V.
VPOS _Channel_A = 4.889V & VNEG_Channel_A= -0.29V
VPOS _Channel_B = 15.32V & VNEG_Channel_B= 0.25V
VPOS _Channel_C = 15.39V & VNEG_Channel_C= 0.22V
VPOS _Channel_D = 4.159V & VNEG_Channel_D= -0.06V
Reference voltage was +4.992V.
Vout and Iout were correct by this time.
Now I connected multimeter to the fourth channel and I've enabled 4th channel and wrote FFFF to it,
After this Vout and Iout were wrong, Read Alarms Channel A and D which are configured as 4-20mA and 0 - 20 mA showed some fault.
I readback the Fault register 0x0B, It returned value as 1739 -> so it means that Channel A Fault and Channel D fault.
Output across the TP1 to TP8 are,
VPOS _Channel_A = 3.207V & VNEG_Channel_A= -0.019V
VPOS _Channel_B = 10.33V & VNEG_Channel_B= -0.121V
VPOS _Channel_C = 10.53V & VNEG_Channel_C= 0.121V
VPOS _Channel_D = 3.467A& VNEG_Channel_D= -0.09V
Reference Voltage read in TP17 is +3.962V.
Input voltage dropped to +3.992V.
Why I can't get a proper Output in Vout and Iout? Can you help me on this asap?
Thanks and regards,
Naveen
Naveen,
I'm sorry, I misunderstood what your problem was. I had thought this was a basic setup problem. However, even after re-reading your posts, I'm not sure what it wrong in the setup. Is your power supply current limited? I could see getting some wrong outputs if the supply is current limited and not powering up the supply correctly. What sort of power supply are you using? And when the output goes wrong can you use a multimeter to read back the supply?
Also, I didn't understand something in your first post. You mentioned: "When I configure 4 channels right, the input supply drops to Vin/4. i.e. Vin = 15, so 15/4 is its 3.8V but for three channels, the output fed to EVM remains as +15V." What is 3.8V? Is that the VPOS_IN_x voltages? Or is that the voltage used for PVDD?
When you have the channel set for current output, what is the load? Are you using one of the resistors on the board? One of the selectable load resistors is 249Ω so with a 20mA output, that would be about a 5V output.
Just to be sure, I did set up the board to duplicate your setup. I set channel 1 as 4-20mA, channel 2 as 0-10V, channel 3 as 0-5V, and channel 4 as 0-20mA. Then I set all of the DACs to FFFF for all outputs. I set the Voltage outputs to no load by inserting none of the shunts and the Current outputs to be 249Ω but inserting shunts for JP19 and JP37. For all the outputs, I get the proper value. Channels 1, 3, and 4 read about 5V while channel 2 reads 10V. The power supply is 15V and draws about 53mA.
If this is a current limited power supply problem, and the current output is causing it, I would test it by setting all outputs to current output and then setting FFFF to all of them. If this is the problem, then the supply may limit after two of the channels are enabled. Note that you'll need to add some load all of the outputs. If you use the 249Ω load for all outputs, and then set the outputs to 20mA for all channels the supply will use about 72mA of current at 15V.
Joseph Wu
I'd changed the power supply, the Evaluation board was working fine with the Evaluation software. Thanks Joseph
Hi Joseph,
I tried connecting DAC8775EVM with STM32H753 Nucleo board, I changed jumpers now I uninstalled JP9 and installed JP11 and JP13 and supplied external power supply of +5V.
I wrote driver code for DAC8775EVM and flashed it, the output was 0V in all channels.
I scoped in AVDD supply and DVDD supply it was +15V and +4.89V but voltage across buck converters was +0.05v V Posx and GND , 0 mA was drawn from power supply.
Then I tried connecting USB-DIG to Eval board again and installed JP9, JP11 and removed JP13. Now I tried through Evaluation software again but after RESET the Voltage across Buck Converters were +0.05V, 0 mA was drawn from power supply..
#include "main.h" #include <stdio.h> enum Operation { RSTREG = 0x01, // Reset RESETCONFIGREG = 0x02, // Reset Config Registerf DACREGISTER = 0x03, DACCFGREGISTER = 0x04, DATAREGISTER = 0x05, BUCKBOOSTREG = 0x06, BUCKBOOSTCFGREG = 0x07, STATUSREG = 0x0B }; /* READ ADDRESS DECODING*/ enum RegisterSelect { RSTATUSREG = 0x00, RDATAREG = 0x01, RCNTRLREG = 0x02 }; /* OUTPUT RANGE OPTIONS */ #define _0_5V 0x0000 // Gain 1 #define _0_10V 0x0001 // Gain 2 #define _PLUS_OR_MINUS_5V 0x0010 // Gain 2 #define _PLUS_OR_MINUS_10V 0x0011 // Gain 4 #define _3_AND_HALF_TO_23_AND_HALF 0x0100 #define _0_20mA 0x0101 #define _0_24mA 0x0110 #define _PLUS_OR_MINUS_24mA 0x0111 #define _0_6V 0x1000 // Gain 1.2 #define _0_12V 0x1001 // Gain 2.4 #define _PLUS_OR_MINUS_6V 0x1010 // Gain 2.4 #define _PLUS_OR_MINUS_12V 0x1011 // Gain 4.8 #define _4_20mA 0x1111 /*RESET REGISTER BITS */ const uint8_t RESETBIT = 0x01; /*CONFIGURATION REGISTER BITS */ const uint16_t CLREND = 0x1000; // Channel D Clear enable const uint16_t CLRENC = 0x0800; // Channel C Clear enable const uint16_t CLRENB = 0x0400; // Channel B Clear enable const uint16_t CLRENA = 0x0200; // Channel A Clear enable const uint16_t REF_EN = 0x0010; // Internal REF enable const uint16_t TRN = 0x0008; // Internal REF enable const uint16_t CLR = 0x0004; // Internal REF enable const uint16_t POC = 0x0002; // Internal REF enable const uint16_t UBT = 0x0001; // Internal REF enable /* Private variables ---------------------------------------------------------*/ SPI_HandleTypeDef hspi4; /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); static void MPU_Config(void); static void MX_GPIO_Init(void); static void MX_SPI4_Init(void); void Set_Latch() { HAL_GPIO_WritePin(GPIOE, GPIO_PIN_11, GPIO_PIN_SET); } void Clear_Latch() { HAL_GPIO_WritePin(GPIOE, GPIO_PIN_11, GPIO_PIN_RESET); } void DAC_8775_Write(uint32_t Data) { uint8_t TxBuffer[3]; TxBuffer[0] = (uint8_t)((Data & 0xff0000)>>16); TxBuffer[1] = (uint8_t)((Data & 0x00ff00)>>8); TxBuffer[2] = (uint8_t)((Data & 0x0000ff)>>0); HAL_SPI_Transmit(&hspi4, (uint8_t *)&TxBuffer , 3 , HAL_MAX_DELAY); Set_Latch(); Clear_Latch(); } uint8_t DAC_8775_Check_Comm(uint8_t Data) { uint32_t Comm_data = ((RESETCONFIGREG << 16) | Data); //Toggling user bit here to check communication DAC_8775_Write(Comm_data); // Reading wrote User bit from Status register Comm_data = (((0x80|STATUSREG) << 16)| Data); //Toggling user bit here to check communication // 0x8B0001 DAC_8775_Write(Comm_data); //Doing NOP to read the value from MISO line DAC_8775_Write(0); return 1; // To add the check logic later } void DAC_8775_Init() { Clear_Latch(); uint32_t ResetConfigData, ResetData, DataWrite = 1, BuckBoostData, BuckBoostConfigData, DACreg, DACConfigData; ResetData = ((RSTREG << 16) | 0x01); //0x01, 0x00, 0x01 = 0x010001 // Reseting the chip by setting the reset bit ResetConfigData = ((RESETCONFIGREG << 16) | REF_EN); //0x02, 0x00, 0x10 = 0x020010 // Enabling Volt reference BuckBoostData = ((BUCKBOOSTREG)<<16| 0x0f); //0x06, 0x00, 0x0f = 0x06000f // 0f --> Selecting all the four DAC channels. BuckBoostConfigData = ((BUCKBOOSTCFGREG<<16)|(0x06<<8)|(0x1f)); //0x07, 0x06, 0x1f = 0x07061f // PNSEL --> Buck boost conv + and - enable, PCLAMP & NCLAMP = +15V and -15V, CCLP = USer can write to PCLMP and NCLMP bits DACreg = ((DACREGISTER<<16)|(0x01<<8)|(0xf0)); //0x03, 0x01, 0xf0 = 0x0300f0 // Selecting CHA,CHB,CHC and CHD and disabling Daisy chain mode DACConfigData = ((DACCFGREGISTER<<16)|(0x10<<8)|(0x10)); //0x04, 0x00, 0x01 = 0x041001 // Selecting Voltage range as 0 to +10V, Disabling Slew rate, Setting OUTEN bit //Reset Chip DAC_8775_Write(ResetData); //Check Communication DAC_8775_Check_Comm(DataWrite); //Reset Config data DAC_8775_Write(ResetConfigData); // Enable Buckboost converter all 4 channel DAC_8775_Write(BuckBoostData); // Config voltage supply for Buckboost converters DAC_8775_Write(BuckBoostConfigData); DAC_8775_Write(DACreg); DAC_8775_Write(DACConfigData); } int main(void) { /* MCU Configuration--------------------------------------------------------*/ uint32_t RxData; uint32_t DataReg; uint8_t rec_buffer[3]; /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* MPU Configuration--------------------------------------------------------*/ MPU_Config(); /* Configure the system clock */ SystemClock_Config(); /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_SPI4_Init(); DAC_8775_Init(); DataReg = (DATAREGISTER<<16|(0xff<<8)|0xff); //Reset Chip DAC_8775_Write(DataReg); RxData = (((0x80|DATAREGISTER)<<16) | 0x00 | 0x00); // 0x85, 0x00, 0x00 = 0x850000 DAC_8775_Write(RxData); while (1) { } } /** * @brief System Clock Configuration * @retval None */ void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; /** Supply configuration update enable */ HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY); /** Configure the main internal regulator output voltage */ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE3); while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {} /** Initializes the RCC Oscillators according to the specified parameters * in the RCC_OscInitTypeDef structure. */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; RCC_OscInitStruct.HSIState = RCC_HSI_DIV1; RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { Error_Handler(); } /** Initializes the CPU, AHB and APB buses clocks */ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2 |RCC_CLOCKTYPE_D3PCLK1|RCC_CLOCKTYPE_D1PCLK1; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI; RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV1; RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV1; RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2; RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV1; if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) { Error_Handler(); } } static void MX_SPI4_Init(void) { /* USER CODE BEGIN SPI4_Init 0 */ /* USER CODE END SPI4_Init 0 */ /* USER CODE BEGIN SPI4_Init 1 */ /* USER CODE END SPI4_Init 1 */ /* SPI4 parameter configuration*/ hspi4.Instance = SPI4; hspi4.Init.Mode = SPI_MODE_MASTER; hspi4.Init.Direction = SPI_DIRECTION_2LINES; hspi4.Init.DataSize = SPI_DATASIZE_8BIT; hspi4.Init.CLKPolarity = SPI_POLARITY_HIGH; hspi4.Init.CLKPhase = SPI_PHASE_1EDGE; hspi4.Init.NSS = SPI_NSS_SOFT; hspi4.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_64; hspi4.Init.FirstBit = SPI_FIRSTBIT_MSB; hspi4.Init.TIMode = SPI_TIMODE_DISABLE; hspi4.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; hspi4.Init.CRCPolynomial = 0x0; hspi4.Init.NSSPMode = SPI_NSS_PULSE_DISABLE; hspi4.Init.NSSPolarity = SPI_NSS_POLARITY_LOW; hspi4.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA; hspi4.Init.TxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN; hspi4.Init.RxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN; hspi4.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE; hspi4.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE; hspi4.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE; hspi4.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE; hspi4.Init.IOSwap = SPI_IO_SWAP_DISABLE; if (HAL_SPI_Init(&hspi4) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN SPI4_Init 2 */ /* USER CODE END SPI4_Init 2 */ } static void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct = {0}; /* GPIO Ports Clock Enable */ __HAL_RCC_GPIOE_CLK_ENABLE(); /*Configure GPIO pin Output Level */ //HAL_GPIO_WritePin(GPIOE, GPIO_PIN_11, GPIO_PIN_RESET); /*Configure GPIO pin : PE11 */ GPIO_InitStruct.Pin = GPIO_PIN_11; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); // PE12 - SPI1 SCLK, PE13 - SPI1 MISO, PE14 - SPI1 MOSI GPIO_InitStruct.Pin = GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 ; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF5_SPI4; HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); } void MPU_Config(void) { MPU_Region_InitTypeDef MPU_InitStruct = {0}; /* Disables the MPU */ HAL_MPU_Disable(); /** Initializes and configures the Region and the memory to be protected */ MPU_InitStruct.Enable = MPU_REGION_ENABLE; MPU_InitStruct.Number = MPU_REGION_NUMBER0; MPU_InitStruct.BaseAddress = 0x0; MPU_InitStruct.Size = MPU_REGION_SIZE_4GB; MPU_InitStruct.SubRegionDisable = 0x87; MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0; MPU_InitStruct.AccessPermission = MPU_REGION_NO_ACCESS; MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE; MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE; MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE; MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE; HAL_MPU_ConfigRegion(&MPU_InitStruct); /* Enables the MPU */ HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT); } void Error_Handler(void) { /* USER CODE BEGIN Error_Handler_Debug */ /* User can add his own implementation to report the HAL error return state */ __disable_irq(); while (1) { } /* USER CODE END Error_Handler_Debug */ } #ifdef USE_FULL_ASSERT void assert_failed(uint8_t *file, uint32_t line) { /* USER CODE BEGIN 6 */ /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* USER CODE END 6 */ } #endif
Is EVM Buck boosters went bad? Can we able to recover EVM if it's a problem with Buck boosters?
We don't have extra EVM and I got stuck with strong project deadlines. One mistake I did is I enabled Internal Voltage reference in RESETCONFIGREGISTER, supplied external voltage and installed JP11 and JP13 as well.
Can this damage DVDD supply? Can I get local Field application engineer(SG) contact for assistance?
Regards,
Naveen
Naveen,
I haven't had a chance to go through all of your code, but I just first want to confirm that the device is still alive and communicating. Can you go back to using the SM-USB-DIG and the EVM GUI to see if it still works? It's likely the fastest way to check. You could check the functionality of the reference, DVDD output/input, and buck-boost.
If that works, I would start by doing something simple - like just writing to the register and reading it back to ensure that the communications are correct. After that, I'd enable the reference and check to see that turned on.
If you connected an external voltage to the internal reference, then it is is possible the EVM is damaged, but I can't be sure of that. I can try to find out if there is an FAE that supports you. I'll message you and figure out the next steps.
Joseph Wu
I tried connecting Evaluation board through USB-DIG and tried seeing it in EVM GUI, I can't able to see the Voltage across across Buck boosters +ve and -ve clamps and reference voltage also but +15V AVDD and +5V external voltage seems to be applied correctly
Hi Joseph,
I've not connected any External reference, i.e. any voltage to J9. I followed the evm user manual, there it is mentioned as To use an external supply voltage as the DVDD supply, install jumpers JP13 and JP11 and uninstall JP9. also if you see the above attached image right J9 wasn't connected and only J4 was connected, that is to supply to DVDD.
So it seems that my connections were correct, I was able to read and write to the chip through Simple I/O tab in EVM GUI. why I wasn't able to see the appropriate voltage across Vpos_X, VNeg_X and Reference?
Have you got a chance to go through my code?
Regards,
Naveen
Naveen,
I did look at the code but I didn't see anything that might be an outright problem. However, I did see that in line 108 that sets up the DAC channels, it should read 0x0301f0 instead of 0x0300f0.
If you're using the Simple I/O to communicate with the EVM and it's working, then I'll assume the EVM is also working. I was able to send your basic initialization sequence (from line 104) and get the device set up (and read the data back). Both the reference voltage came up to 5V and the VPOS_IN and VNEG_IN were set to ±15. To test your code, I'd just concentrate on just starting up the reference. It's the simplest command that sets a voltage on the board that you can measure.
One thing that might help is to use a logic analyzer to view the 0x020010 command that sets the reference voltage. If the Simple I/O works, view that command first, and compare it with yours.
Joseph Wu
Naveen,
I think that an FAE has contacted you already, but to make sure everyone is on the same page, please keep posting here. This way, everyone can view the comments.
One thing that was recently mentioned was the CPOL and CPHA. I generally use CPOL as 0 so that the SCLK idles low. However, I think that CPOL as 1 would still work. The important thing is that the data is clocked in at the falling edge of SCLK, so CPHA is 1 in this case. Can you verify this is the case in your code? It would be very helpful to get a scope shot of your communications to verify this and the other timing and construction of your communications.
Another thing that I wasn't sure about is the DVDD. In previous posts, the DVDD was external, for which you had the DVDD LDO disabled, and the external DVDD enabled (through installing J11 and J13). Regardless if you use an internal or external DVDD, the DVDD and the microcontroller supply should be the same. If the DVDD is 5V and the microcontroller is running on 3V, the output of the micro will never be high enough to set a logical high voltage.
Again, I still think that you need to start with a simple command to enable the reference, just to verify the communications. Once you get the scope shots on that, post the digital communications back to this thread.
Joseph Wu
Hi Joseph,
I connected +15v between AVDD and GND, disconnected USB-DIG, disconnected JP9, J11 and JP13 and connected SPI on TP's (Enabled internal DVDD LDO). I flashed simple code to set FFFF on Channel 1, there was no data from MISO line and when I measured across TP17 and GND it was 0v (Reference voltage) similarly between TP20 and GND it is 0v. This was seen with Old board.
/** ****************************************************************************** * @file : main.c * @brief : Main program body ****************************************************************************** * @attention * * Copyright (c) 2022 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** #include "main.h" #include <stdio.h> #include <string.h> /*ADDRESS BYTE FUNCTIONS */ /*const uint8_t AD_NOP = 0x00; const uint8_t DATA_REGISTER = 0x01; const uint8_t READBACK = 0x02; const uint8_t CNTRLREG = 0x55; const uint8_t RSTREG = 0x56; */ enum Operation { AD_NOP = 0x00, DATA_REGISTER = 0x01, READBACK = 0x02, CNTRLREG = 0x55, RSTREG = 0x56 }; /* READ ADDRESS DECODING*/ enum RegisterSelect { RSTATUSREG = 0x00, RDATAREG = 0x01, RCNTRLREG = 0x02 }; /* const uint8_t RSTATUSREG = 0x00; const uint8_t RDATAREG = 0x01; const uint8_t RCNTRLREG = 0x02; */ /* OUTPUT RANGE OPTIONS */ #define _0_5V 0x00 #define _0_10V 0x01 #define _4_20mA 0x05 #define _0_20mA 0x06 #define _0_24mA 0x07 /*RESET REGISTER BITS */ const uint8_t RESETBIT = 0x01; /*CONFIGURATION REGISTER BITS */ const uint8_t RESETREGISTER = 0x00; // Register operation to be added separately const uint8_t SLEWRATE_EN = 0x10; const uint8_t SR_STEP1_16 = 0x00; //0 const uint8_t SR_STEP1_8 = 0x20; //1 const uint8_t SR_STEP1_4 = 0x40; //2 const uint8_t SR_STEP1_2 = 0x60; //3 const uint8_t SR_STEP1_1 = 0x80; //4 const uint8_t SR_STEP_2 = 0xA0; //5 const uint8_t SR_STEP_4 = 0xC0; //6 const uint8_t SR_STEP_8 = 0xE0; //7 const uint16_t OUTEN = 0x2000; const uint16_t REXT = 0x1000; void SystemClock_Config(void); static void MPU_Config(void); static void MX_GPIO_Init(void); static void MX_SPI4_Init(void); static void DAC8775_Init(void); void Set_Latch() { HAL_GPIO_WritePin(GPIOE, GPIO_PIN_11, GPIO_PIN_SET); } void Clear_Latch() { HAL_GPIO_WritePin(GPIOE, GPIO_PIN_11, GPIO_PIN_RESET); } /** * @brief The application entry point. * @retval int */ int main(void) { /* MCU Configuration--------------------------------------------------------*/ uint32_t DAC_Reg_Write = 0x05ffff; uint8_t TxBuf[3]; /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* MPU Configuration--------------------------------------------------------*/ MPU_Config(); /* Configure the system clock */ SystemClock_Config(); /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_SPI4_Init(); DAC8775_Init(); TxBuf[0] = (uint8_t)((DAC_Reg_Write & 0xff0000)>>16); TxBuf[1] = (uint8_t)((DAC_Reg_Write & 0x00ff00)>>8); TxBuf[2] = (uint8_t)((DAC_Reg_Write & 0x0000ff)>>0); HAL_SPI_Transmit(&hspi4, (uint8_t *)&TxBuf , 3 , HAL_MAX_DELAY); // Transmitting Configured Buffer value to AD5422 Set_Latch(); Clear_Latch(); while (1) { } } /** * @brief System Clock Configuration * @retval None */ void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; /** Supply configuration update enable */ HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY); /** Configure the main internal regulator output voltage */ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE3); while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {} /** Initializes the RCC Oscillators according to the specified parameters * in the RCC_OscInitTypeDef structure. */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; RCC_OscInitStruct.HSIState = RCC_HSI_DIV1; RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { Error_Handler(); } /** Initializes the CPU, AHB and APB buses clocks */ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2 |RCC_CLOCKTYPE_D3PCLK1|RCC_CLOCKTYPE_D1PCLK1; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI; RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV1; RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV1; RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2; RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV1; if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) { Error_Handler(); } } static void DAC8775_Init(void) { Set_Latch(); Clear_Latch(); uint32_t Reset = 0x010001; uint32_t Enable_BuckBoost = 0x060001; uint32_t Config_BuckBoost = 0x07001f; // 0x0700001 -- 1f -> Default settings, 01 only pos clamp enabled uint32_t Enable_ref = 0x020010; uint32_t Select_DAC = 0x030030; uint32_t Config_DAC = 0x041001; int32_t Readvalue = 0; uint8_t Rxbuffer[3] = {0, 0, 0}; uint8_t TxBuf[3]; TxBuf[0] = (uint8_t)((Reset & 0xff0000)>>16); TxBuf[1] = (uint8_t)((Reset & 0x00ff00)>>8); TxBuf[2] = (uint8_t)((Reset & 0x0000ff)>>0); HAL_SPI_Transmit(&hspi4, (uint8_t *)&TxBuf , 3 , HAL_MAX_DELAY); Set_Latch(); Clear_Latch(); //HAL_Delay(500); memset(TxBuf,0,sizeof(TxBuf)); TxBuf[0] = (uint8_t)((Enable_BuckBoost & 0xff0000)>>16); TxBuf[1] = (uint8_t)((Enable_BuckBoost & 0x00ff00)>>8); TxBuf[2] = (uint8_t)((Enable_BuckBoost & 0x0000ff)>>0); HAL_SPI_Transmit(&hspi4, (uint8_t *)&TxBuf , 3 , HAL_MAX_DELAY); Set_Latch(); Clear_Latch(); //HAL_Delay(500); memset(TxBuf,0,sizeof(TxBuf)); TxBuf[0] = (uint8_t)((Config_BuckBoost & 0xff0000)>>16); TxBuf[1] = (uint8_t)((Config_BuckBoost & 0x00ff00)>>8); TxBuf[2] = (uint8_t)((Config_BuckBoost & 0x0000ff)>>0); HAL_SPI_Transmit(&hspi4, (uint8_t *)&TxBuf , 3 , HAL_MAX_DELAY); Set_Latch(); Clear_Latch(); //HAL_Delay(500); memset(TxBuf,0,sizeof(TxBuf)); TxBuf[0] = (uint8_t)((Enable_ref & 0xff0000)>>16); TxBuf[1] = (uint8_t)((Enable_ref & 0x00ff00)>>8); TxBuf[2] = (uint8_t)((Enable_ref & 0x0000ff)>>0); HAL_SPI_Transmit(&hspi4, (uint8_t *)&TxBuf , 3 , HAL_MAX_DELAY); Set_Latch(); Clear_Latch(); uint32_t Data = 0x820000; TxBuf[0] = (uint8_t)((Data & 0xff0000)>>16); TxBuf[1] = (uint8_t)((Data & 0x00ff00)>>8); TxBuf[2] = (uint8_t)((Data & 0x0000ff)>>0); HAL_SPI_Transmit(&hspi4, (uint8_t *)&TxBuf , 3 , HAL_MAX_DELAY); Set_Latch(); Clear_Latch(); TxBuf[0] = (uint8_t)((0x000000 & 0xff0000)>>16); TxBuf[1] = (uint8_t)((0x000000 & 0x00ff00)>>8); TxBuf[2] = (uint8_t)((0x000000 & 0x0000ff)>>0); HAL_SPI_TransmitReceive(&hspi4, (uint8_t *)&TxBuf , (uint8_t *)&Rxbuffer, 3 , HAL_MAX_DELAY); Set_Latch(); Clear_Latch(); Readvalue |= (int32_t) (Rxbuffer[1] << 8); Readvalue |= (int32_t) (Rxbuffer[2] << 0); //HAL_Delay(500); memset(TxBuf,0,sizeof(TxBuf)); TxBuf[0] = (uint8_t)((Select_DAC & 0xff0000)>>16); TxBuf[1] = (uint8_t)((Select_DAC & 0x00ff00)>>8); TxBuf[2] = (uint8_t)((Select_DAC & 0x0000ff)>>0); HAL_SPI_Transmit(&hspi4, (uint8_t *)&TxBuf , 3 , HAL_MAX_DELAY); Set_Latch(); Clear_Latch(); //HAL_Delay(500); memset(TxBuf,0,sizeof(TxBuf)); TxBuf[0] = (uint8_t)((Config_DAC & 0xff0000)>>16); TxBuf[1] = (uint8_t)((Config_DAC & 0x00ff00)>>8); TxBuf[2] = (uint8_t)((Config_DAC & 0x0000ff)>>0); HAL_SPI_Transmit(&hspi4, (uint8_t *)&TxBuf , 3 , HAL_MAX_DELAY); Set_Latch(); Clear_Latch(); } /** * @brief SPI4 Initialization Function * @param None * @retval None */ static void MX_SPI4_Init(void) { /* SPI4 parameter configuration*/ hspi4.Instance = SPI4; hspi4.Init.Mode = SPI_MODE_MASTER; hspi4.Init.Direction = SPI_DIRECTION_2LINES; hspi4.Init.DataSize = SPI_DATASIZE_8BIT; hspi4.Init.CLKPolarity = SPI_POLARITY_HIGH; // Clock Idle State High hspi4.Init.CLKPhase = SPI_PHASE_1EDGE; // FALLING EDGE hspi4.Init.NSS = SPI_NSS_SOFT; hspi4.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_64; hspi4.Init.FirstBit = SPI_FIRSTBIT_MSB; hspi4.Init.TIMode = SPI_TIMODE_DISABLE; hspi4.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; hspi4.Init.CRCPolynomial = 0x0; hspi4.Init.NSSPMode = SPI_NSS_PULSE_DISABLE; hspi4.Init.NSSPolarity = SPI_NSS_POLARITY_LOW; hspi4.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA; hspi4.Init.TxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN; hspi4.Init.RxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN; hspi4.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE; hspi4.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE; hspi4.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE; hspi4.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE; hspi4.Init.IOSwap = SPI_IO_SWAP_DISABLE; if (HAL_SPI_Init(&hspi4) != HAL_OK) { } } /** * @brief GPIO Initialization Function * @param None * @retval None */ static void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct = {0}; /* GPIO Ports Clock Enable */ __HAL_RCC_GPIOE_CLK_ENABLE(); /*Configure GPIO pin Output Level */ //HAL_GPIO_WritePin(GPIOE, GPIO_PIN_11, GPIO_PIN_RESET); /*Configure GPIO pin : PE11 */ GPIO_InitStruct.Pin = GPIO_PIN_11; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); // PE12 - SPI1 SCLK, PE13 - SPI1 MISO, PE14 - SPI1 MOSI GPIO_InitStruct.Pin = GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 ; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF5_SPI4; HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); } /* MPU Configuration */ void MPU_Config(void) { MPU_Region_InitTypeDef MPU_InitStruct = {0}; /* Disables the MPU */ HAL_MPU_Disable(); /** Initializes and configures the Region and the memory to be protected */ MPU_InitStruct.Enable = MPU_REGION_ENABLE; MPU_InitStruct.Number = MPU_REGION_NUMBER0; MPU_InitStruct.BaseAddress = 0x0; MPU_InitStruct.Size = MPU_REGION_SIZE_4GB; MPU_InitStruct.SubRegionDisable = 0x87; MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0; MPU_InitStruct.AccessPermission = MPU_REGION_NO_ACCESS; MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE; MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE; MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE; MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE; HAL_MPU_ConfigRegion(&MPU_InitStruct); /* Enables the MPU */ HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT); } /** * @brief This function is executed in case of error occurrence. * @retval None */ void Error_Handler(void) { /* USER CODE BEGIN Error_Handler_Debug */ /* User can add his own implementation to report the HAL error return state */ __disable_irq(); while (1) { } /* USER CODE END Error_Handler_Debug */ } #ifdef USE_FULL_ASSERT /** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */ void assert_failed(uint8_t *file, uint32_t line) { /* USER CODE BEGIN 6 */ /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* USER CODE END 6 */ } #endif /* USE_FULL_ASSERT */
Please find the SPI captures.
I also tried connecting EVM to GUI tool. Reset, enabled Internal ref, Enabled Buck boost converters, enabled Output and wrote values as FFFF in DAc data registers. I'm able to Readback the wrote value as FFFF.
But Vout was 0. I then read status of Reset config register 0x02, it is 0x10 - so Reference is enabled
I then read Status register 0x0B - It is 0x1400 - so Buck boost Converter D alone is in good condition.
So Simple I/O is working why I wasn't able to readback the same through SPI while connected to TP's, Why was Output isn't shown properly?
Also, to test with new board
Can I connect +15v between AVDD and GND, disconnect USB-DIG, disconnect JP9, J11 and JP13 and connect SPI pins from MCU on TP's ? This connection is correct right?
Hi Joseph,
I was using DC power supply to power up DVDD J4 and not from Microcontroller.
Regards,
Naveen
Naveen,
I think your connections are correct. The 15V supply goes from PVDD/AVDD to GND through J2. JP9 removed disconnects the SM-USB-DIG supply from DVDD; JP11 installed disables the DVDD LDO output; and JP13 installed selects the external DVDD. Note that table 3 in the EVM user's guide has the jumper labels and functions just in case. Also, you can use the test pins on the upper left side of the EVM to connect the SPI pins. The DVDD supply can be connected to J4. Just make sure the DVDD that you use is the same voltage as the microcontroller.
If the simple I/O is working, then using an external microcontroller should work as well. The SM-USB-DIG is really just attaching an external microcontroller.
I think this is either an microcontroller SPI setup problem, where the device is not getting the correct version of SPI, or a connection problem where the SPI isn't received or the board isn't set up correctly.
For the logic analyzer shot that you sent, can you send a picture of each transmission? The detail is too small to see the individual commands. Send a picture for each command. If this logic analyzer is a Saleae, then you can send the analyzer file. I have the software to read that data.
Can you send a picture of the board with how you have it set up? It might help to have labels to show where you have everything connected.
Joseph Wu
Also, to test with new board
Can I connect +15v between AVDD and GND, disconnect USB-DIG, disconnect JP9, J11 and JP13 and connect SPI pins from MCU on TP's ? This connection is correct right?
Regards,
Naveen
Naveen,
It looks like in this case, you have JP11 and JP13 removed. In that case, DVDD_EN is left floating which should enable the internal DVDD and the external DVDD should not be used. Looking at the picture I don't see any external connection to the DVDD line which looks correct. Because the DVDD is enabled you should be able to measure the DVDD line, which I would expect to be near 5V.
I asked this in a previous post, but what voltage is the microcontroller running at? Again if the microcontoller is running at 3V, then the logical high may not be received as a high voltage by the DAC.
Last, and probably most important, I looked at your commands from the logic analyzer. For each of the commands you sent 25 SCLKs. The proper form of command is that the frame is 24 SCLKs. With the extra SCLK, I don't think the device is reading any proper command. Correct this and see if the device responds.
Joseph Wu
It looks like in this case, you have JP11 and JP13 removed. In that case, DVDD_EN is left floating which should enable the internal DVDD and the external DVDD should not be used. Looking at the picture I don't see any external connection to the DVDD line which looks correct. Because the DVDD is enabled you should be able to measure the DVDD line, which I would expect to be near 5V -- Yes I've not connected External DVDD Supply I can't able to see 5V in DVDD Tp's
I asked this in a previous post, but what voltage is the microcontroller running at? - 5V
Last, and probably most important, I looked at your commands from the logic analyzer. For each of the commands you sent 25 SCLKs. The proper form of command is that the frame is 24 SCLKs. - It's a Glitch on Logic analyzer and SCLK is 24. The first part is a glitch of Logic analyzer
Naveen,
First, when I power up the board, the supply pulls about 3-4 mA at the start (without initializing anything). If I pull out the jumper at J11, I can immediately see the DVDD supply come up (I read 5.1V on my DMM). If I put the jumper back in, then the DVDD supply goes back to 0V. Can you check that again? Maybe start by disconnecting everything except the supply.
I saw the image that you put for the STLINK-V3E and I get that the USB connection is 5V, but I need to make sure that the microcontroller is also running at 5V. It's extremely likely that there is some LDO that sets the micro's power supply. On the STM page describing this board, it says that the multi-path bridge USB to SPI is 3V to 3.6V application support, so I'm not sure if the micro itself is really running at 5V. One thing that you can do is to set the Saleae to measure the analog voltages for all of these digital signals. This way you can verify the voltages for the transmission and communication. Again, if you save this Saleae file to the post, I'll be able to read it.
Also, by setting the Saleae to also read the analog voltages, you can verify that there isn't a real glitch on the Saleae and that the micro is sending only 24 SCLKs. How do you know that this is a glitch with the logic analyzer and not really an extra SCLK pulse?
Joseph Wu
Hi joseph,
How do you know that this is a glitch with the logic analyzer and not really an extra SCLK pulse? - Sorry it wasn't a glitch, there was some extra piece of code I removed it now the data is sent correctly.
I tried enabling Internal reference of DAC8775EVM using SPI in new evaluation board. I sent data to DAC8775EVM and read back but internal reference bit wasn't enabled. Please find the DAC captures.
Also Microcontroller runs at 3.6v. The 5v from USB is fed to LDO Voltage regulator and LDO supplies 3.3v to STM32. I'll attach info about LDO.
So In this case how can I make DAC8775EVM work?. Please help me as I got stuck here for so long time.
Regards,
Naveen
Naveen,
If the microcontroller signals are 3.3 and the DAC DVDD is 5V, then there may be a problem with the signals not going high enough to reach digital voltage high. In that case you would disable the DVDD LDO (by inserting JP11 disables DVDD LDO) and then attach the 3.3V from the microcontroller to the DVDD. This matches the digital voltages and levels for the DAC and the micro.
Note that I did test enabling the reference. The SPI SCLK idles low, and is clocked in (and out) on the falling edge. For the scope photos:
Yellow: /CS
Blue: DIN
Pink: SCLK
Green: DOUT
Here is the write to enable the reference.
Here is the read back of the register.
This does enable the reference and I can see the 5V output after writing the reference enable.
Joseph Wu
Hi Joseph,
This time I used DVDD ( Connected to external port J4 & Jumper J11 and J13 is inserted ) of Microcontroller +3.3v to powerup the DAC8775EVM. I tried the readback sequence. I wasn't able to readback the value properly. I attach the code and captures here.
Can you please help me here quickly, I got stuck in this for so long time. I can't even establish communication and turn on the reference.
/* USER CODE BEGIN Header */ /** ****************************************************************************** * @file : main.c * @brief : Main program body ****************************************************************************** * @attention * * Copyright (c) 2023 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include "main.h" #include <string.h> /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ /* USER CODE BEGIN PTD */ /* USER CODE END PTD */ /* Private define ------------------------------------------------------------*/ /* USER CODE BEGIN PD */ /* USER CODE END PD */ /* Private macro -------------------------------------------------------------*/ /* USER CODE BEGIN PM */ /* USER CODE END PM */ /* Private variables ---------------------------------------------------------*/ SPI_HandleTypeDef hspi4; /* USER CODE BEGIN PV */ /* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); static void MPU_Config(void); static void MX_GPIO_Init(void); static void MX_SPI4_Init(void); /* USER CODE BEGIN PFP */ /* USER CODE END PFP */ /* Private user code ---------------------------------------------------------*/ /* USER CODE BEGIN 0 */ /* USER CODE END 0 */ void Set_Latch() { HAL_GPIO_WritePin(GPIOE, GPIO_PIN_11, GPIO_PIN_SET); } void Clear_Latch() { HAL_GPIO_WritePin(GPIOE, GPIO_PIN_11, GPIO_PIN_RESET); } static void DAC8775_Init(void) { uint32_t Reset = 0x010001; //uint32_t Enable_BuckBoost = 0x060001; //uint32_t Config_BuckBoost = 0x07001f; // 0x0700001 -- 1f -> Default settings, 01 only pos clamp enabled uint32_t Enable_ref = 0x020010; //uint32_t Select_DAC = 0x030030; //uint32_t Config_DAC = 0x041001; int32_t Readvalue = 0; uint8_t Rxbuffer[3] = {0, 0, 0}; uint8_t TxBuf[3]; TxBuf[0] = 0x01;//(uint8_t)((Reset & 0xff0000)>>16); TxBuf[1] = 0x00;//(uint8_t)((Reset & 0x00ff00)>>8); TxBuf[2] = 0x01;//(uint8_t)((Reset & 0x0000ff)>>0); HAL_SPI_Transmit(&hspi4, (uint8_t *)&TxBuf , 3 , HAL_MAX_DELAY); Set_Latch(); Clear_Latch(); memset(TxBuf,0,sizeof(TxBuf)); TxBuf[0] = 0x02;//(uint8_t)((Enable_ref & 0xff0000)>>16); TxBuf[1] = 0x00;//(uint8_t)((Enable_ref & 0x00ff00)>>8); TxBuf[2] = 0x10;//(uint8_t)((Enable_ref & 0x0000ff)>>0); HAL_SPI_Transmit(&hspi4, (uint8_t *)&TxBuf , 3 , HAL_MAX_DELAY); Set_Latch(); Clear_Latch(); uint32_t Data = 0x820000; TxBuf[0] = 0x82;//(uint8_t)((Data & 0xff0000)>>16); TxBuf[1] = 0x00;//(uint8_t)((Data & 0x00ff00)>>8); TxBuf[2] = 0x00;//(uint8_t)((Data & 0x0000ff)>>0); HAL_SPI_Transmit(&hspi4, (uint8_t *)&TxBuf , 3 , HAL_MAX_DELAY); Set_Latch(); Clear_Latch(); TxBuf[0] = 0x00;//(uint8_t)((0x000000 & 0xff0000)>>16); TxBuf[1] = 0x00;//(uint8_t)((0x000000 & 0x00ff00)>>8); TxBuf[2] = 0x00;//(uint8_t)((0x000000 & 0x0000ff)>>0); HAL_SPI_TransmitReceive(&hspi4, (uint8_t *)&TxBuf , (uint8_t *)&Rxbuffer, 3 , HAL_MAX_DELAY); Set_Latch(); Clear_Latch(); Readvalue |= (int32_t) (Rxbuffer[0] << 16); Readvalue |= (int32_t) (Rxbuffer[1] << 8); Readvalue |= (int32_t) (Rxbuffer[2] << 0); } /** * @brief The application entry point. * @retval int */ int main(void) { /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MPU Configuration--------------------------------------------------------*/ MPU_Config(); /* MCU Configuration--------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_SPI4_Init(); DAC8775_Init(); /* USER CODE BEGIN 2 */ /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ } /* USER CODE END 3 */ } /** * @brief System Clock Configuration * @retval None */ void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; /** Supply configuration update enable */ HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY); /** Configure the main internal regulator output voltage */ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE3); while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {} /** Initializes the RCC Oscillators according to the specified parameters * in the RCC_OscInitTypeDef structure. */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; RCC_OscInitStruct.HSIState = RCC_HSI_DIV1; RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { Error_Handler(); } /** Initializes the CPU, AHB and APB buses clocks */ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2 |RCC_CLOCKTYPE_D3PCLK1|RCC_CLOCKTYPE_D1PCLK1; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI; RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV1; RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV1; RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2; RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV1; if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) { Error_Handler(); } } /** * @brief SPI4 Initialization Function * @param None * @retval None */ static void MX_SPI4_Init(void) { /* USER CODE BEGIN SPI4_Init 0 */ /* USER CODE END SPI4_Init 0 */ /* USER CODE BEGIN SPI4_Init 1 */ /* USER CODE END SPI4_Init 1 */ /* SPI4 parameter configuration*/ hspi4.Instance = SPI4; hspi4.Init.Mode = SPI_MODE_MASTER; hspi4.Init.Direction = SPI_DIRECTION_2LINES; hspi4.Init.DataSize = SPI_DATASIZE_8BIT; hspi4.Init.CLKPolarity = SPI_POLARITY_LOW; hspi4.Init.CLKPhase = SPI_PHASE_1EDGE; hspi4.Init.NSS = SPI_NSS_SOFT; hspi4.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_64; hspi4.Init.FirstBit = SPI_FIRSTBIT_MSB; hspi4.Init.TIMode = SPI_TIMODE_DISABLE; hspi4.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; hspi4.Init.CRCPolynomial = 0x0; hspi4.Init.NSSPMode = SPI_NSS_PULSE_ENABLE; hspi4.Init.NSSPolarity = SPI_NSS_POLARITY_LOW; hspi4.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA; hspi4.Init.TxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN; hspi4.Init.RxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN; hspi4.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE; hspi4.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE; hspi4.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE; hspi4.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE; hspi4.Init.IOSwap = SPI_IO_SWAP_DISABLE; if (HAL_SPI_Init(&hspi4) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN SPI4_Init 2 */ /* USER CODE END SPI4_Init 2 */ } /** * @brief GPIO Initialization Function * @param None * @retval None */ static void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct = {0}; /* GPIO Ports Clock Enable */ __HAL_RCC_GPIOE_CLK_ENABLE(); /*Configure GPIO pin : PE11 */ GPIO_InitStruct.Pin = GPIO_PIN_11; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); // PE12 - SPI1 SCLK, PE13 - SPI1 MISO, PE14 - SPI1 MOSI GPIO_InitStruct.Pin = GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 ; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF5_SPI4; HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); } /* USER CODE BEGIN 4 */ /* USER CODE END 4 */ /* MPU Configuration */ void MPU_Config(void) { MPU_Region_InitTypeDef MPU_InitStruct = {0}; /* Disables the MPU */ HAL_MPU_Disable(); /** Initializes and configures the Region and the memory to be protected */ MPU_InitStruct.Enable = MPU_REGION_ENABLE; MPU_InitStruct.Number = MPU_REGION_NUMBER0; MPU_InitStruct.BaseAddress = 0x0; MPU_InitStruct.Size = MPU_REGION_SIZE_4GB; MPU_InitStruct.SubRegionDisable = 0x87; MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0; MPU_InitStruct.AccessPermission = MPU_REGION_NO_ACCESS; MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE; MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE; MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE; MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE; HAL_MPU_ConfigRegion(&MPU_InitStruct); /* Enables the MPU */ HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT); } /** * @brief This function is executed in case of error occurrence. * @retval None */ void Error_Handler(void) { /* USER CODE BEGIN Error_Handler_Debug */ /* User can add his own implementation to report the HAL error return state */ __disable_irq(); while (1) { } /* USER CODE END Error_Handler_Debug */ } #ifdef USE_FULL_ASSERT /** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */ void assert_failed(uint8_t *file, uint32_t line) { /* USER CODE BEGIN 6 */ /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* USER CODE END 6 */ } #endif /* USE_FULL_ASSERT */
Thanks and regards,
Naveen
Naveen,
From the logic analyzer pictures, it looks like you have the SPI set up incorrectly. The DIN should be changing on the rising edge of SCLK and stable through the falling edge of SCLK where it is read by the device. In your shots, the actions are opposite, the data changes on the falling edge of SCLK and are stable through the rising edge of SCLK. With this timing, the data would be incorrect (and may appear as shifted by a bit).
It does look like the SDO is clocking out data. Once you set up the SPI correctly, I would expect that you would be able to read from and write to the device.
Joseph Wu