View previous topic :: View next topic |
Author |
Message |
ressas
Joined: 15 Nov 2019 Posts: 135
|
|
Posted: Wed Nov 20, 2019 8:12 am |
|
|
Thank you Ttelmah |
|
|
ressas
Joined: 15 Nov 2019 Posts: 135
|
|
Posted: Wed Nov 20, 2019 8:19 am |
|
|
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
|
FDC2214 vs FDC2112 |
Posted: Mon Nov 25, 2019 2:38 am |
|
|
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: 9113 Location: Greensville,Ontario
|
|
Posted: Mon Nov 25, 2019 6:05 am |
|
|
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
|
|
Posted: Mon Nov 25, 2019 6:20 am |
|
|
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
|
|
Posted: Tue Nov 26, 2019 1:32 am |
|
|
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: 19225
|
|
Posted: Tue Nov 26, 2019 2:04 am |
|
|
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!... |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9113 Location: Greensville,Ontario
|
|
Posted: Tue Nov 26, 2019 2:00 pm |
|
|
LSW MSW ?? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19225
|
|
Posted: Wed Nov 27, 2019 1:17 am |
|
|
Exactly. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9113 Location: Greensville,Ontario
|
|
Posted: Wed Nov 27, 2019 5:38 am |
|
|
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 ?
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: 19225
|
|
Posted: Wed Nov 27, 2019 6:45 am |
|
|
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>
|
|
|
ressas
Joined: 15 Nov 2019 Posts: 135
|
|
Posted: Sat Nov 30, 2019 1:30 am |
|
|
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." |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19225
|
|
Posted: Sat Nov 30, 2019 1:52 am |
|
|
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
|
|
Posted: Sat Nov 30, 2019 2:44 am |
|
|
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. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19225
|
|
Posted: Sat Nov 30, 2019 3:04 am |
|
|
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. |
|
|
|