Hi, I'm trying to read from the FIFO Buffer off of the MMA8652FC Accelerometer.
I currently have it set up where the Buffer mode is set to be a Fill Buffer and the Watermark is set to 32 samples. I also have F_READ (Fast Read mode) enabled, so that the data I'm reading in is only 8-bits.
I do understand that whenever F_MODE is greater than 0, the OUT_X_MSB (0x01) register becomes the root pointer to XYZ FIFO data.
With this in mind, when I try to read and access the FIFO samples from OUT_X_MSB, it only returns 0x80 96 times. So it's clear I'm accessing the FIFO data improperly, however I cannot figure out why.
Note that I am able to access the data normally with the FIFO buffer disabled
The code I am using to read off of the FIFO is this:
void accel_BufRead(uint8* Data_Ptr){
uint8 numBytes=96; //96 because I'm reading 32 samples of 8-bit XYZ data thus 32*3=96
uint8 Write_Buf[1] = {0};
uint8 *Write_Ptr = &Write_Buf;
Write_Buf[0] = 0x01;
I2C_1_MasterWriteBuf(Addr, Write_Ptr, 1, I2C_1_MODE_NO_STOP);//Addr is the slave address, Write_Ptr is the register address, I2C_1_MODE_NO_STOP
//indicates a mode where it will execute an I2C transfer without a Stop
while(0u == (I2C_1_MasterStatus() & I2C_1_MSTAT_WR_CMPLT)){} //Check if the write process was successful and completed
I2C_1_MasterReadBuf(Addr, Data_Ptr, numBytes, I2C_1_MODE_REPEAT_START);//Addr is the slave address, Data_Ptr is where the data will be stored,
//numBytes= 96 bytes of data expected to read, I2C_MODE_REPEAT_START
//indicates mode where it will execute an I2C transfer
//by sending a Repeat Start instead of a Start
while(0u == (I2C_1_MasterStatus() & I2C_1_MSTAT_RD_CMPLT)){} //Check if the read process was successful and completed
return;
}
解決済! 解決策の投稿を見る。
Hi Andrew,
It is hard to say where the problem might be, but attached you can find my example code I just wrote to test it. Accelerometer setting can be found in the MMA8652FC_Init function.
Here you can see some screenshots illustrating correct behavior.
F_READ = 1, so the data is 8-bits only:
ODR is set to 800Hz, so the FIFO interrupt happens every 40 ms (1.25 ms x 32 samples):
Let me know whether or not this helps, or if you have any other questions.
Regards,
Tomas
PS: If my answer helps to solve your question, please mark it as "Correct" or “Helpful”. Thank you.
Hi Andrew,
It is hard to say where the problem might be, but attached you can find my example code I just wrote to test it. Accelerometer setting can be found in the MMA8652FC_Init function.
Here you can see some screenshots illustrating correct behavior.
F_READ = 1, so the data is 8-bits only:
ODR is set to 800Hz, so the FIFO interrupt happens every 40 ms (1.25 ms x 32 samples):
Let me know whether or not this helps, or if you have any other questions.
Regards,
Tomas
PS: If my answer helps to solve your question, please mark it as "Correct" or “Helpful”. Thank you.
Hi Tomas,
Thank you so much for replying to my question. Your sample code made me realize that the read function provided in Cypress' PSoC library just wasn't doing what I needed it to do. So I rewrote their read function and it seems like it is finally properly functioning. Thank you so much! This is the data output I get now.
I polled the INT1 Pin to see if the interrupt was functioning properly and for the most part it is. There are times where it gets a strange signal where it goes low and high and low and high again. Here's a picture of what I'm talking about:
Do you have any ideas of why that's happening? Just to make sure, the only thing I need to clear the interrupt is read the F_STATUS (0x00) register right?
Hi Andrew,
Glad to see it works now. I would recommend reading the FIFO only, as you can see in my sample code. Then you should not get the second pulse on the INT1 pin.
I hope it helps.
Regards,
Tomas