Strictly necessary cookies are on by default and cannot be turned off. Functional, Performance and Tracking/targeting/sharing cookies can be turned on below based on your preferences (this banner will remain available for you to accept cookies). You may change your cookie settings by deleting cookies from your browser. Then this banner will appear again. You can learn more details about cookies HERE.
Strictly necessary (always on)
Functional, Performance and Tracking/targeting/sharing (default off)
I'm using the Cypress example code projects to try to get data from an accelerometer (ADcmXL3021). I'm using the UsbSpiDmaMode project, where I've merged GPIO functionality into it.
When I'm trying to communicate with the accerlerometer, I'm using SPI communication. The UsbSpiDmaMode already has functions set up for this; CyFxSpiTransfer (programmer application), which uses the two functions CyU3PSpiTransmitWords and CyU3PSpiReceiveWords.
Currently, I've tried making my own functions to write and read data over the SPI interface. They look as follows:
with startSampling() and readData().
As you can see I pass in 0x3E, 0x08, 0x00 as my input, which you can also read in the datasheet for the accelerometer are the registers that start recording data. The datasheet can be found here:
(where 0x3E is the address for GLOB_CMD and 0x08 (0x0800) is the address to start recording).
My output gives the same values, which implies that I'm using the functions incorrectly. Below, my data value (200 entries) are seen from the UART debugger:
It would obviously be best if I could use the given function, CyFxSpiTransfer, but I get stuck in the CyFxSpiWaitForStatus() function when I try using it with the call: CyFxSpiTransfer(0x003E, 0x0800, 4, CyFalse)
(I'm unsure what the 3rd parameter means (*buffer).
I've seen you're employee, juchong, has made a GitHub FX3 API which includes this accelerometer, but I can't seem to understand it and how it works (I'm new to this world). It's found here:
Moreover, can I use the CyU3PSpiTransferWords function to combine the two (transmit and recieve) into one? If so, that would be much better of course.
If you could tell me where I go wrong, in the calls of the given functions, it would help me out very much! I hope it's a simple fix. All I want to do is invoke the RTS mode (later the MFFT mode) of the ADcmXL3021 accelerometer, and get a single reading of the mode for each iteration call from the main function of my program (located in the AppThread_entry function). The AppThread_entry function looks like below:
Hope I've provided enough information, other please tell me if you need more information. I've also attached the C-file to this message.