![]() I think the DAC would work in other modes, but the method for reading the data might be different (see pg 19). Had to change the SPI MODE, i don't really understand why it works at SPI_MODE3. Msg1 = msg1 | B10000000 // CODEn + DAC selection ( MAX5724 datasheet) Void dacWrite (int CS, int value, int channel) SPI.setDataMode(CS, SPI_MODE3) //this is correct none of the others work Quick question i can only have 3 of these per arduino due right? On CS line 4,10,52? #include I got it working with this code thanks a lot for your help (tidied up the code a bit and made it generic)! Had to change the SPI MODE, i don't really understand why it works at SPI_MODE3 and why if i change the clock to about 20MHz, when the datsheet (page1) says it should work up to 50MHz.Ĭan i change the VDD (analog supply voltage) to 5V and the Vref to 5v, while leaving VDDIO (Digital Supply Voltage) to 3.3v, so i can out 5V and not damage my arduino due? byte msg1 = 0b11000010 īut what seems to happen is the register ignores the first binary number in each msg and adds a 1 to the end of each msg so my output is doing code_n on channel 101 (channel 5) and setting it 0, code below is what is actually output (number in brackets at the end is what is oddly added and number in brackets at the start is what is ignored) byte msg1 = 0b(1)1000010(1) The code below i expect would according to the data sheet code_all and load_all and all channels would change to 512 about half voltage. The code above seems to work however it does not send correctly. SPI.setClockDivider(CS, 21) // low to start with SPI.setDataMode(CS, SPI_MODE0) //this is correct I have managed to move some outputs however, i have some very weird findings. SPI.transfer(CS, msg3) // CS goes HIGH after transferĪye i need 8 channels so that wouldn't help, the LDAC can be held low which makes DAC registers transparent and CLR can be held high (). SPI.transfer(CS, msg1, SPI_CONTINUE) // CS goes LOW SPI Serial Interface Timing Diagram MAX5724 I haven't used this IC, however it seems you have some connection problems.ġ6 IRQ Arduino Input Optional, 5K pullup to 3.3V, low = watchdog timeoutġ8 LDAC Arduino Output Normally HIGH 3.3V I thought with the code in my previous post above i would be able to change the outputs to 5V and the DAC would stay at 5V until i changed it to a different value, but they don't do anything and stay at default MZ. I however can't get the outputs to change at all, bit stumped at the moment. I am reading the output of each channel with an oscilloscope. Once i have the outputs changing i was going to change each channel individually. I assume with CODE_ALL LOAD_ALL (page 22 2nd in the table) it would change all 8 outputs to data being sent. I am trying to change the output of the 8 channels. Since i have the LDAC connected to GND i think i can just use the CODEn command on page 21 of the datasheet.ĭo i need to read before i write? I just want to write to the DAC's outputs don't really care what they send back. ![]() Either i misunderstood the datasheet in the wiring or im writing incorrectly to it. Interestingly, I only get those outputs with SPI_MODE2, with the others i get all zeros (val1 0, val2 0, val1 hex 0).I have a MAX5724 8 channel 10 bit DAC's connected to a due, i believe i have it wired up correctly, however when i try to write a value to it doesn't seem to output anything. As you can see in the output, val1 shows 11000000, val2 0 and val1 in HEX is C0. I'm printing val1 and val2 in binary to see what i'm getting from the sensor. Val1 = SPI.transfer(0) // transfer byte 1 SPISettings settingsA(100000, MSBFIRST, SPI_MODE2) ĭigitalWrite(SS,HIGH) // Setting SlaveSelect as HIGH (So master doesnt connnect with slave) I've tried this new code and got an interesting output: #include I even tried on an arduino uno just in case but still nothing. Thanks robtillaart for the code, sadly i get the same output as last time. Value += digitalRead(dataPin) // digitalRead returns 0 or 1 the sensor selection works with SS/CS LOWįor (int b = 0 b < 32 b++) // read 32 bits Using XIAO's D3/A3 pin for the SS/CS of the sensorĬonst int clockPin = 4 // <<< must be adjustedĬonst int dataPin = 5 // << must be adjusted Picture of the handshake in your first post. Please try this sketch, it does not use the SPI library but "emulates it" based upon the My next step would be to skip the SPI library and use bit-banging to fetch the data. So the sensor does not send any data using the SPI library.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |