CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

SPI c code problem

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Monk9514524
Guest







SPI c code problem
PostPosted: Sat Oct 25, 2008 10:05 am     Reply with quote

The following was part of SPI code for PIC16F88
Code:
  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

View user's profile Send private message

SPI c code problem
PostPosted: Sat Oct 25, 2008 10:12 am     Reply with quote

Here is the original code for Triple Axis Accelerometer.

http://www.sparkfun.com/datasheets/Sensors/LIS3LV02DQ-Tester.zip

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

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Sat Oct 25, 2008 10:24 am     Reply with quote

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

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Oct 25, 2008 2:34 pm     Reply with quote

Monk,
If you search the Sparkfun forum, you will find a driver by KamPutty:
http://forum.sparkfun.com/viewtopic.php?p=18666
Monk9514524
Guest







thanks for help~PCM programmer
PostPosted: Sun Oct 26, 2008 3:13 am     Reply with quote

Thanks for your kindness PCM programmer and KamPutty.

I was really troubled by this question for a period of time.

Now I can try to move on to next stage.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group