|
|
View previous topic :: View next topic |
Author |
Message |
ELCouz
Joined: 18 Jul 2007 Posts: 427 Location: Montreal,Quebec
|
Arduino to CCS |
Posted: Fri Jan 08, 2016 9:30 pm |
|
|
Hi,
I'm trying to test an arduino library with CCS.
Anyone knows the equivalent of shiftIn function in CCS?
Code: | byte incoming = shiftIn(dataPin, clockPin, bitOrder)
Example: data = shiftIn(SDO,SCK,MSBFIRST);
|
Thanks! _________________ Regards,
Laurent
-----------
Here's my first visual theme for the CCS C Compiler. Enjoy! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19537
|
|
Posted: Sat Jan 09, 2016 2:38 am |
|
|
Use the CCS SPI functions.
On the Arduino, you generally use Shiftin, to perform the equivalent of SPI, on a pin that doesn't support the hardware SPI. It generates a clock and shifts a bit in from a pin (just like SPI).
The CCS SPI library supports operation both on the hardware peripheral, or on any pins using a software function. Both are built in to the single library. Nice thing is that the software functions this produces are tightly optimised.
So just declare the #USE SPI, to use the pins, edges, speed, bit order etc., and then use spi_xfer to get the byte or word.
CCS can also effectively shiftout at the same time, and spi_xfer can be told how many bits to shift (so you can for instance send/get 32bits in a single transaction. The CCS SPI functions also allow you to program the clock polarity, which edge to read on, the maximum rate to use etc.. The function can also be programmed to automatically operate CS if required (there is a _lot_ hidden in the CCS SPI library....).
|
|
|
|
|
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
|