SPI master, send decimal numbers

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
HaHa_285681
Level 3
Level 3
First like given

Hi to everyone, 

   


I need to send decimal numbers via SPI master, but  SPIM_WriteTxData(), can send only hex numbers.
How to send decimals? how can I convert them to hex and then put in SPIM_WriteTxData() function? 

   


regards,
Hakob

0 Likes
17 Replies
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

The SPIU writes _binary_ data. It does not care about hex vs. decimal, this is something you need to handle in your program.

   

Maybe you can explain a little bit more about what you actually want to do?

0 Likes
HaHa_285681
Level 3
Level 3
First like given

I have a function which gives, five outputs (int8 decimal) and I need to send them via SPI master to external DAC to get output volts.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Can you evolve whether your function values are ASCII characters (which I doubt) or just the values ? When you provide us with a link to your DAC we can probably help you better.

   

 

   

Bob

0 Likes
HaHa_285681
Level 3
Level 3
First like given

Dear Bob,

   

I will check for it for ASCII.
Do I need to save the files of my function as a ASCII? 
Here is details of my DAC 
http://www.analog.com/media/en/technical-documentation/data-sheets/AD5308_5318_5328.pdf

   

regards,
Hakob

0 Likes
HaHa_285681
Level 3
Level 3
First like given

It is  c89/c90(ANSI) 

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Your datasheet shows that you will have to transmit 16 bit binary words to your DAC, no decimal, no ASCII. Look at the serial interface description of the DAC which shows exactly what is expected.

   

You will have to do some bit-merging in C-language to construct the values to transmit.

   

 

   

Bob

0 Likes
HaHa_285681
Level 3
Level 3
First like given

Dear Bob,

   

it is my DAC, it doesn't respond as it must, I have to change.
I had given hex numbers corresponding to its binary command and followed SPIM output signals via oscilloscope. Clocking signals and data signals were expected as binary command. Anyway it doesn't respond for some DACs and 256 resolution.
Can you suggest some known DAC which vould work corectly ?

   

regards,
Hakob 

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Sorry Hakob,

   

I am a digital man. Someone else will have to support you with analog information. What are the specs that have to be fulfilled for your DAC?

   

 

   

Bob

0 Likes
HaHa_285681
Level 3
Level 3
First like given

I need to generate some biological potentials.

   

regards,
Hakob

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

With "Specs" I mean Electrical specifications as

   

Supply voltage, accuracy, precision speed etc.

   

 

   

Bob

0 Likes
HaHa_285681
Level 3
Level 3
First like given

I need to generate approximately 100 step voltage graph by random value (between 0-2 volt).

   

regards,
Hakob

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

This would mean that an 8-bit DAC would be sufficient, no external part needed except when needed an amplifier. So what is the reason you do not use an internal DAC

   

 

   

Bob

0 Likes
HaHa_285681
Level 3
Level 3
First like given

I have 4-5 outputs, in PSOC 5LP only 2 DACs.

   

regards,
Hakob

0 Likes
Anonymous
Not applicable

Hi Hakop
 

   

maybe you can use the DACs followed by analog multiplexer ?

   

All the Best
Frank

0 Likes
HaHa_285681
Level 3
Level 3
First like given

Hi Franksanderdo

   

​ I need 5 different outputs as random voltage sources. Can I use one VDAC and one multiplexer and do what I want ? 

   

regards,

   

Hakob

0 Likes
Anonymous
Not applicable

Hi Hakop,

   

sorry for late answer.
You can feed from one VDAC into a multiplexer and then into a sample and hold circuit.
PSOC 5LP has sample and hold component, but (unfortunately) not enough resources to do 5,
Last time I have used a capacitor / opamp combination combination to sample & hold the output.

   

All the Best
Frank

0 Likes
HaHa_285681
Level 3
Level 3
First like given

Hi Franksanderdo,

   

I have solved the problem by changing cy8c5468axi-lp106 (has 2 VDAC) to cy8c5868axi-lp 032 (has 4 VDAC).

   

Regards ,

   

Hakob

0 Likes