16 bit dac spi arduino12/18/2023 ![]() ![]() * This function sends a Nop command to the DAC161 on the SPI bus. Unsigned short resetCode = DAC161_RESET_VALUE ĭAC161_Write_Regs (&resetCode, DAC161_RESET_REG, 2) ĭAC161_Write_Regs (&resetCode, DAC161_NOP_REG, 2) // Nop required after reset * This function sends a Reset command to the DAC161 on the SPI bus. SpiHandle = RegisterSpiDevice (ste_port, ste_pin) ĭAC161_Write_Regs (&errConfig, DAC161_ERR_CONFIG_REG, 2) ĮrrValue = DAC161_CONVERT_ERR_VALUE(errLow_uA) & 0x7f00 ĭAC161_Write_Regs (&errValue, DAC161_ERR_LOW_REG, 2) ĮrrValue = DAC161_CONVERT_ERR_VALUE(errHigh_uA) & 0xff00 ĭAC161_Write_Regs (&errValue, DAC161_ERR_HIGH_REG, 2) Void Setup_DAC161 (Port_t ste_port, unsigned char ste_pin, unsigned short errConfig, unsigned short errLow_uA, unsigned short errHigh_uA) ![]() * errHigh_uA Output level (micro Amps) for a High Error ![]() * errLow_uA Output level (micro Amps) for a Low Error * errConfig Error Configuration for the DAC161 (DAC161_STD_ERR_CONFIG) * ste_pin The MSP430 pin that contains the CS or STE pin that is connected to the DAC161. * ste_port The MSP430 port that contains the CS or STE pin that is connected to the DAC161. * This function will configure the DAC161. Performs actual read of previous address SPI_Write (SpiHandle, outData, readValues, lengthBytes+1) // Add 1 to length for command byte Void DAC161_Read_Regs (unsigned char *readValues, unsigned char startReg, unsigned char lengthBytes) * startReg Address of the first register to read * *readValues Pointer to place the 8 bit register values from the DAC161 No error checking is performed, so it is the user's responsibility to make sure they do not attempt to read past This function can be used to read one or more * This function will execute a read register command to the DAC161 and return the resultant data. SPI_Write (SpiHandle, outData, RcvData, lengthBytes+1) // Add 1 to length for command byte SPI.beginTransaction(SPISettings(6000000, MSBFIRST, SPI_MODE0)) Ĭhange_SPI_Phase (SPI_CAPT_ON_FIRST_EDGE) When I try using the library posted above, I change the dac161s997_spi_xfer function to try and make it work with the STM32, and put it into the main sketch: #include Įrror_t dac161s997_spi_xfer(dac161s997_dev_t *dev, uint8_t* tx_buf, I am first trying to get general communications to work before I try and port it into a SFOC Driver, but I have not the embedded systems knowledge to know how to easily communicate with it. Library: GitHub - Accelovant/dac161s997: Platform independent driver for the DAC161S997 4/20mA driver chip The DAC circuit will provide a 4-20mAh loop circuit, controlled by writing to one of its registers. The device is a DAC controlled over SPI from a STM32L05C8T6 MCU, which will be used to send data from my motor back to a PLC over long distances. Hello, I have a question about implementing an SPI device into: ![]()
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |