Jump to content

jimk3038

Members
  • Content Count

    6
  • Joined

  • Last visited

  1. This might be cool too. Call CmdT() to start a temperature conversion. Inside CmdT() a timestamp is set to record millis() which returns the system milliseconds since powerup. Then, in GetNodeData() a check is made that a minimum of 750 milliseconds has elapsed. This would allow an application to call CmdT() to start a conversion, do some other processing, and then return later to collect the results. The code, I think - untested, would look like the following. Just an idea to allow other things to happen while a temperature conversion is happening on the bus. uint32_t convertTimestamp; void DS18B20::CmdT( void ) { reset(); write_byte( 0xCC ); // skip ROM command write_byte( 0x44 ); // convert T command OW_HI convertTimestamp = millis(); // Set timestamp } int32_t DS18B20::GetNodeData( uint8_t rom[8] ) { int32_t stemp; // Wait for temp conversion to complete. while( convertTimestamp + 750 > millis() ); reset(); write_byte( 0x55 ); // Choose ROM for ( uint8_t i = 0; i < 8; i++ ) write_byte( rom[i] ); write_byte( 0xBE ); // read scratchpad command uint16_t temp = ReadDS1820(); if ( temp & 0xF800 ) // Handle negative values. stemp = ((int32_t)(~temp) + 1) * -1; else stemp = (int32_t)temp; // Return value as degrees C times 10. return( stemp * 625 / 1000 ); }
  2. The following code works even better if you have multiple sensors on the same bus. The following code also handles negative values. Simply call CmdT() first - all the sensors on the bus make a temperature measurement at the same time. Then, call GetNodeData( addr[] ) for each sensor on the bus. With several sensors on the bus this method is much faster. I'm reading three sensors in under a second. Jim void DS18B20::CmdT( void ) { reset(); write_byte( 0xCC ); // skip ROM command write_byte( 0x44 ); // convert T command OW_HI delay( 750 ); // Delay in milliseconds. } int32_t DS18B20::GetNodeData( uint8_t rom[8] ) { int32_t stemp; reset(); write_byte( 0x55 ); // Choose ROM for ( uint8_t i = 0; i < 8; i++ ) write_byte( rom[i] ); write_byte( 0xBE ); // read scratchpad command uint16_t temp = ReadDS1820(); if ( temp & 0xF800 ) // Handle negative values. stemp = ((int32_t)(~temp) + 1) * -1; else stemp = (int32_t)temp; // Return value as degrees C times 10. return( stemp * 625 / 1000 ); }
  3. Grant, Thanks for a great library - saved me a bunch of time. I added the following function so now I can read temperatures from multiple sensors on the same wire. Seems "GetData" and "GetData10" functions are designed to read from a single sensor on the bus. WIth multiple sensors, all the sensors try to respond and step on each other. The function "GetNodeData" fixes that. Thanks again, Jim int32_t DS18B20::GetNodeData( uint8_t rom[8] ) { uint8_t i; uint16_t temp; reset(); write_byte(0x55); // Choose ROM for ( i = 0; i < 8; i++ ) write_byte(rom[i]); //write_byte(0xcc); // skip ROM command write_byte(0x44); // convert T command OW_HI delay(750); // had incorrectly used delayMicroseconds() reset(); write_byte(0x55); // Choose ROM for ( i = 0; i < 8; i++ ) write_byte(rom[i]); //write_byte(0xcc); // skip ROM command write_byte(0xbe); // read scratchpad command temp = ReadDS1820(); int16_t stemp = (int16_t)temp; return((int32_t)stemp*625/1000); }
  4. jimk3038

    Anyone building CMSIS under Linux?

    Was any solution ever found for this problem? I hit the same issue while trying to get FreRTOS up and running. Everything works great until memset is called - which seem to generate a hard fault. Even TI's stock example "/stellarisware/boards/ek-lm4f120xl/freertos_demo/gcc/freertos_demo.bin" locks up.
  5. jimk3038

    Application RAM Usage

    Sorry about not indicating where the snipit came from. Here is a link to the source article. Yeah, I did find the temperary files that Erengia is making after a build is complete. However, there were no memory map files generated. Is there a way to adjust a setting to have Erengia generate a map file? Looks like (according to the link above) "At any point in time, there is a highest point in RAM occupied by the heap. This value can be found in a system variable called __brkval." Here is another good link - however, it's all about an Arduino. This guy has shows a couple of diagrams descibing memory layout. Again, for the Arduino. I'm guessing the problem is just with the spelling of the variables `__brkval' and `__heap_start'. Must be some varant of these? Thanks for the suggestions, Jim
  6. jimk3038

    Application RAM Usage

    I'm trying to keep an eye on the amount of RAM my application is using. After a bit of searching, I found the following code that returns the current amount of RAM that is being used. However, the function throws a compiler error about some undefined variables. Is this the right approach to find current RAM usage? Or, is there something else I should be using with Energia? Thanks, Jim // Return the current amount of RAM used. // ---------------------------------------------------------------------------- int freeRam () { extern int __heap_start, *__brkval; int v; return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); } Flasher2.cpp.o: In function `freeRam()': C:\DOCUME~1\James\LOCALS~1\Temp\build4403779855877337752.tmp/Flasher2.cpp:178: undefined reference to `__brkval' C:\DOCUME~1\James\LOCALS~1\Temp\build4403779855877337752.tmp/Flasher2.cpp:178: undefined reference to `__heap_start' collect2: ld returned 1 exit status
×