Go Down

Topic: OneWire in Due (Read 21 times) previous topic - next topic

AWOL

Code: [Select]
void OneWire::select( uint8_t rom[8])
{
    int i;  // overkill
...
    for( i = 0; i < 8; i++) {
}
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

alvesjc

Ok, thanks.

I'll ask my friend to test this also. ;)

regards,

Joao

alvesjc


Code: [Select]
void OneWire::select( uint8_t rom[8])
{
    int i;  // overkill
...
    for( i = 0; i < 8; i++) {
}



Sorry, I don't understand what you mean!

mantoui

#13
Jan 11, 2013, 02:20 am Last Edit: Jan 11, 2013, 02:22 am by mantoui Reason: 1
I rewrote  write_bit() in OneWire.cpp to match (more or less) what was working on the maple.  This seems to work for me without any delay(1);!  Works on both the little ds18b20 sketch and the Examples>OneWire>DS18x20_temperature.

Code: [Select]

void OneWire::write_bit(uint8_t v)
{
IO_REG_TYPE mask=bitmask;
volatile IO_REG_TYPE *reg IO_REG_ASM = baseReg;

if (v & 1) {
// noInterrupts();
DIRECT_MODE_OUTPUT(reg, mask); // drive output low
DIRECT_WRITE_LOW(reg, mask);
delayMicroseconds(5);
// DIRECT_WRITE_HIGH(reg, mask); // drive output high
DIRECT_MODE_INPUT(reg, mask); // let pin float, pull up will raise
delayMicroseconds(60);
//interrupts();
} else {
//noInterrupts();
DIRECT_MODE_OUTPUT(reg, mask); // drive output low
DIRECT_WRITE_LOW(reg, mask);
delayMicroseconds(60);
DIRECT_MODE_INPUT(reg, mask); // let pin float, pull up will raise
//DIRECT_WRITE_HIGH(reg, mask); // drive output high
//interrupts();
}
delayMicroseconds(10); // 10uSec recovery time
}

kcore

Great job gentlemen!

I combined mantoui's updated OneWire::write_bit function along with the changes made by alvesjc and I'm now able to run the DS18x20_Temperature right out of the box.

This effort should go a long way in getting other people moved over to the Due because so many projects have requirements to read temperatures and interact with other one wire devices.

Thanks for all your help in getting this working.

I've put all the stuff in a zip file for others to test without having to edit the files.

Go Up