Jump to content
43oh

single

Members
  • Content Count

    4
  • Joined

  • Last visited

Reputation Activity

  1. Like
    single got a reaction from leomar01 in Reading the ds18b20 temperature sensor   
    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)
×
×
  • Create New...