Jump to content

single

Members
  • Content Count

    4
  • Joined

  • Last visited

  1. How much code memory does it need? Will it fits in msp430g2452?
  2. I've made a few tests, this code starts working good from 5Mhz. At lower frequencies readout unstable or impossible. BUT I find a way how to run this algorithm with DCO on 1 MHz. All you need is to rewrite the arduino-like part using defines instread of using functions. This is my code: //------------------------------------------------------------------------------ // Arduino like digitalRead, pinMode, and digitalWrite and some other helper functions. //------------------------------------------------------------------------------ #define LOW 0 #define HIGH 1 #define INPUT 0 #define OUTPUT 1 #define delayMicroseconds(n) __delay_cycles(1*n) #define delay(n) delayMicroseconds(1000u*n) #define digitalRead(Pin) (P1IN & 1 << Pin) >> Pin #define setOUTPUT(pin) P1DIR |= (1 << pin) #define setINPUT(pin) P1DIR &= (~(1 << pin)) #define pinMode(pin, out) set##out(pin) #define setHIGH(pin) P1OUT |= (1 << pin) #define setLOW(pin) P1OUT &=(~(1 << pin)) #define digitalWrite(pin, bit) set##bit(pin)
  3. page 3 of datasheet for ds18s20 shows method how we can get more accurate results, than 0.5 degree. After reading scratchpad we will need 4 values: 1) Temperature: ScratchPad[0] 2) Sign: ScratchPad[1] 3) Count_remain: ScratchPad[6] 4) Count_per_C: ScratchPad[7] //it always equals 16 so, code should looks like this: LowByte = ScratchPad[0]; HighByte = ScratchPad[1]; COUNT_REMAIN = ScratchPad[6]; COUNT_PER_C = ScratchPad[7]; if (HighByte) TReading = -LowByte; else TReading = LowByte; Tc_100 = ((TReading * 50) - 25 + ((COUNT_PER_C - COUNT_REMAIN)*100) / COUNT_PER_C)/10; /* //a little bit faster version is Tc_100 = ((TReading * 50) - 25 + (((16 - COUNT_REMAIN)*100) >> 4))/10 */ Whole = Tc_100 / 10; Fract = Tc_100 % 10;
  4. I would like to thank NatureTM for this topic and say that if someone afraid to apply this method, then there is no reason. Official TI page offers code samples for MSP430G2xx1 that includes file msp430x20xx_dco_flashcal.c which almost identical with the file on the second page of this topic, written by zeke and needs no DCO library, so this is at least semi-official method :thumbup:
×
×
  • Create New...