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

Need help for i2c communication with FDC2214
Goto page Previous  1, 2, 3, 4, 5  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ressas



Joined: 15 Nov 2019
Posts: 135

View user's profile Send private message

PostPosted: Wed Nov 20, 2019 8:12 am     Reply with quote

Thank you Ttelmah
ressas



Joined: 15 Nov 2019
Posts: 135

View user's profile Send private message

PostPosted: Wed Nov 20, 2019 8:19 am     Reply with quote

Yep, ı read Ttelmah's answer
he is right
The last code I sent did not appear in bold
you use (unsigned int32)
you dont use (unsigned long)
adn use (printf("%lu",capa[i]);)

dont use (printf("%ud",capa[i]);)
ressas



Joined: 15 Nov 2019
Posts: 135

View user's profile Send private message

FDC2214 vs FDC2112
PostPosted: Mon Nov 25, 2019 2:38 am     Reply with quote

Hello again,
I want to re-adapt the code I wrote. I used the code in the FDC2214 integration and got a good result. Now I want to use the FDC2112 integrated. The only difference between these two integrated; 2214 = 24 bits, 2112 = 12 bits.
I didn't see a difference in the datasheet. How do I update my Write () and Read () functions?
temtronic



Joined: 01 Jul 2010
Posts: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Nov 25, 2019 6:05 am     Reply with quote

I looked and didn't see how to change the 'configuration' to change from 16 bit to 28 bit readings .... perhaps there's an 'application note' on the mfrs website or even use Google 'FDC2214 28bit mode' ?

Once that is done though just read the 2 16 bit channel results and use the 'make32()' function to combine the high word and low word into a 32 bit result. Strip( remove) the upper 4 bits and what's left shouldbe the 28 bit , 'high resolution' value. The datasheet shows the bit patterns....
You will have to code for 'out of range' numbers though. That at least is in the datasheet !

edit update...
this...
unsigned int32 getReading28(unsigned int8 channel) {

is the function you call in the driver, so all the 'work' is done for you !!

I looked at the code and still can't see where 28bit vs 16 bit configuration is done though...
ressas



Joined: 15 Nov 2019
Posts: 135

View user's profile Send private message

PostPosted: Mon Nov 25, 2019 6:20 am     Reply with quote

thank you for your answer. but I can run the 28-bit integrated properly. I can't get that 12-bit integrated.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Nov 26, 2019 1:32 am     Reply with quote

Look at the data sheet. It's the same data sheet for all the devices, either
12-bit or 28-bit. Look at page 15, at Table 4. Sample Data Registers.
http://www.ti.com/lit/gpn/fdc2112
Table 4 shows how to interpret the data registers for each type of device.
The 3rd column is for 12-bit devices. It shows that the data you need is
in this register: DATA_CH0, addr 0x00.

Use that information to re-write your code, if necessary.
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Tue Nov 26, 2019 2:04 am     Reply with quote

There is a slight confusion in the code which doesn't help.
It uses:
Code:

    reading = ((unsigned int32) read16FDC(addressMSB) & FDC2214_DATA_CHx_MASK_DATA) << 16;
    reading |= read16FDC(addressLSB);

Referring here to the two reads as LSB & MSB, but in fact each read
here is a 16bit word.
The first read here returns the 12bit data from the lower resolution
chip. If you don't rotate this, and get rid of the second read, you
have the data required.

There is a query on this. The data sheet shows the second register
as 'not applicable' on the low resolution chip, but also has the comment
that
Quote:

The DATA_CHx.DATAx register must always be read first, followed by the DATA_LSB_ CHx.DATAx register of the same channel to
ensure data coherency


So it may be that you actually have to perform the 32bit read as in the
existing code, and then simply take the upper 16bits of this. However I
would suspect that 'data coherency' here is referring to correct alignment
of the upper and lower words, so in fact it'd be OK to just do the first
read.

Having a manufacturer refer to words using LSB and & MSB, really should
be a capital offence!... Smile
temtronic



Joined: 01 Jul 2010
Posts: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Nov 26, 2019 2:00 pm     Reply with quote

LSW MSW ??
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Wed Nov 27, 2019 1:17 am     Reply with quote

Exactly. Very Happy
temtronic



Joined: 01 Jul 2010
Posts: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Nov 27, 2019 5:38 am     Reply with quote

hmm... there's NO Google find of LSW meaning Least Significant Word.
Wonder if I can 'copyright' the term and make my 'millions' on royalties ? Laughing
I'm kinda surprised though, considering some computers 'think' in 32 or 64 bits....
sorry to digress, I'll go back to 'playing with PICs'...
Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Wed Nov 27, 2019 6:45 am     Reply with quote

LSW, and MSW have been used for years. Puzzled at the Google result.
Got datasheets using these here.

If you search for 'lsw least significant word', Google finds stuff from
Siemens using the term, and Modbus. Also the acronyms dictionary has LSW.

<https://acronyms.thefreedictionary.com/Least+Significant+Word>

Very Happy
ressas



Joined: 15 Nov 2019
Posts: 135

View user's profile Send private message

PostPosted: Sat Nov 30, 2019 1:30 am     Reply with quote

Hello Ttelmah, thank you for answers.
Quote:
If you don't rotate this, and get rid of the second read, you
have the data required.

I don't know exactly what you want to say here.

Just keep the first reading and let the second go?
Code:

reading = ((unsigned int32) read16FDC(addressMSB) & FDC2214_DATA_CHx_MASK_DATA);// << 16;
 //reading |= read16FDC(addressLSB);

And when you say the first code rotation; You mean "return reading." Crying or Very sad
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Sat Nov 30, 2019 1:52 am     Reply with quote

Yes.

The rotation is the <<16. You show this remmed out.

What is happening is that two _word_ reads are being done one after the
other. The result of the first one is effectively multiplied by 65536, moving
it into the upper 16bits of a 32bit value, then is combined with the result
of the second reading.
Now the second reading is the 'LSW' of the 28bit value. On the chip only
returning 12 bits this contains nothing.
ressas



Joined: 15 Nov 2019
Posts: 135

View user's profile Send private message

PostPosted: Sat Nov 30, 2019 2:44 am     Reply with quote

Kodu bu şekilde yazdım. Fakat bir sonuç alamadım. Seri porttan sadece 0 değerli okuyorum.
Code:

 reading = ((unsigned int32) read16FDC(addressMSB) & FDC2214_DATA_CHx_MASK_DATA);
   // reading |= read16FDC(addressLSB);


I wonder if there is a problem with the i2c_read part. Because I'm reading 16 bits in that function. Question
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Sat Nov 30, 2019 3:04 am     Reply with quote

NO, THAT IS EXACTLY RIGHT....

This is why I was 'moaning' about the nomenclature being used in the
function and the data sheet where they refer to the two 16 bit _words_
as 'LSB & MSB, rather than as words.

The read16FDC function returns 16bits from the chip.

The first read done is of the register that on the 28bit chip contains the
upper 12bits of the value.
The second read then fetches the low 16bits and combines these two values.
On the 12bit chip, it is the low 12bits of the 16bit value returned by the
first read, that is the value you need to be using.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2, 3, 4, 5  Next
Page 2 of 5

 
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