Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

sending 32bit values in mikroc SPI

Status
Not open for further replies.

varunme

Advanced Member level 3
Advanced Member level 3
Joined
Aug 10, 2011
Messages
741
Helped
17
Reputation
36
Reaction score
17
Trophy points
1,318
Visit site
Activity points
5,765
can we send a value like
int a=0b00000001000000000000000000000000;

in mikroc spi like as below?

int a=0b00000001000000000000111000000011;
SPI1_Write(a);
 

You don't mention the device you are using but most of the PIC18, the PIC24/dsPIC33 and the PIC32 families can have the SPI peripherals transfer either 8 or 16 bits at a time (the PIC32 family can do 32 bits per transfer).
I do not know how to set this up using the mikroC libraries but this is very easy do do (I would say 'trivial' personally as this is the way I always do it) by addressing the SPI registers yourself.
the other advantage is that you *know* what is happening in terms of blocking (or not) and error handling within the functions.
Susan
 

That does not really tell us much - which device would have been more useful.
Also what is the slave expecting?
If it is using a 'standard' mode, then the fact there is likely to be a bit of a break in the SCK in between bytes (remember the SCK is only active during an exchange in this mode) will not make much difference as bits are only clocked on the specified edge of the clock.
However if you are using a framing mode then you may be better off 'bit-banging' the SPI interface.
Susan
 
  • Like
Reactions: varunme

    varunme

    Points: 2
    Helpful Answer Positive Rating
hello


can we send a value like
int a=0b00000001000000000000000000000000;

NO, because
before sending it trough SPI mode ,
you must first define your variable "a" as an unsigneg long ! 32 bits size.

Code:
 unsigne long  a=0b00000001000000000000000000000000;
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top