Some help with C code!!!

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Some help with C code!!!

3,506 Views
damitsi
Contributor I
Does anybody knows a C code to do the communication between MC908GP32 and the sensor SHT11?
At Sensirion's site it has a sample code for 80c51 family microcontroller.

Thanks
Labels (1)
0 Kudos
7 Replies

776 Views
peg
Senior Contributor IV
Hi damitsi,
 
I am sure we have been here before but I can't find it. Maybe it was a slightly different part?
Maybe someone else remembers?
 
Regards
Peg
 
Found the one I was thinking of, not sure if its relevant:
 
 

Message Edited by peg on 2007-01-2307:22 AM

0 Kudos

776 Views
damitsi
Contributor I
Hi peg, first of all i would like to thank you for your help about the
communication problem that i had. Second thanks again for your link in
this forum. Now I will work on it and we will see.
 
Regards,
Jim
0 Kudos

776 Views
bigmac
Specialist III
Hello,
 
As previously noted, the sample code from the Sensiron website uses floating point calculations for determining temperature, RH and dew point from the raw sensor data.  The use of floating point may exceed the resources of many low end MCU devices, and should be avoided, if possible.  It does seem to be feasible to use integer calculations for temperature and humidity, but not for dew point (at least not for simple coding).
 
The attached code would replace the calc_sth11() function of the sample code, and would provide temperature resolution of 0.1C, and humidity resolution of 0.1%RH, using short variables instead of float.  This code should be much less expensive of MCU resources, assuming dew point calculation is not required.
 
Regards,
Mac
 
0 Kudos

776 Views
bigmac
Specialist III
Hello,
 
The previous thread quoted by Peg is relevant to all devices in the family, including the SHT11.  The sample C code on the Sensiron website should readily adapt to the MC9(S)08 series, since it appears to simply bit-bang the I/O pins.
 
You would need to define the DATA and SCK signals against the I/O you are using.  Note that, for the DATA signal, you would actually be controlling the associated DDR bit, as discussed in the earlier thread.  With this arrangement, the send data would be inverted, but the receive data would not - probably not applicable to 80C51 devices with open drain I/O configuration.
 
For example, if you were to use PTA0 for data, and PTA1 for clock -
 
#define  DATA  DDRA_DDRA0
#define  SCK   PTA_PTA1
 
Also note the previous comments with respect to floating point calculations done by the sample code.
 
Regards,
Mac
 

Message Edited by bigmac on 2007-01-2305:05 PM

0 Kudos

776 Views
alex_spotw
Contributor III
Hi:

If the sample code is in C, you should not have big trouble using it with the HCs08 compiler. Could you post that sample code?

Regards,

Alex R.
0 Kudos

776 Views
damitsi
Contributor I
Hi  alex_spotw, for the sample code go to
and download the (Sample Code humidity sensor SHTxx .pdf )
 
Thank you for your interest
 
Regards,
 Jim
0 Kudos

776 Views
UcTechnoGeek
Contributor II
What kind of interface is it?
 
Since the GP32 was one of the first 908 devices released, I would take a look at the 908AP32.  It's a similar device at a lower cost.
 
Better yet, take a look at the 9S08GT32A.  Faster, lower power and has the built in BDM (much better for debugging).  Best of all, it even cost less.
 
Just my two cents.
 
uCTechnoGeek
0 Kudos