for(x = 0 ; x < 8 ; x++)
{
SDI = outgoing_byte.7; //Put bit on SPI data bus
outgoing_byte <<= 1; //Rotate byte 1 to the left
SCL = 0; //Toggle the SPI clock
SCL = 1;
incoming_byte <<= 1; //Rotate byte 1 to the left
incoming_byte.0 = SDO; //Read bit on SPI data bus
}
I try to transfer it to be used on PIC18F452 with CCS,
but there are some problems such as the outgoing_byte.7.
It should be take as the highest bit of outgoing_byte
but I never see that before.
I don't know if that program can be accepted by CCS.
Otherwise how I can change that into my own ?
Thx for all your answer.
Monk666
Joined: 25 Oct 2008 Posts: 2
SPI c code problem
Posted: Sat Oct 25, 2008 10:12 am
Here is the original code for Triple Axis Accelerometer.
I am trying to transfer this code to be use in my PIC18F452 with CCS.
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
Posted: Sat Oct 25, 2008 10:24 am
If you are interested I sell a $20 driver for this sensor written in Microchip C30 for the PIC24 family using hardware SPI. It would be straight forward to port to CCS and I can assist you to do it.
In the my application the driver was used to scan X, Y & Z every 2ms (500Hz). The driver is capable of a higher sampling rate but I was also using a Magnetometer that was not capable of sampling faster. _________________ Regards, Andrew
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum