Library for ds2413

Post here all questions related to LibMaple core if you can't find a relevant section!
Post Reply
Naveen
Posts: 3
Joined: Sat Aug 08, 2020 10:52 am

Library for ds2413

Post by Naveen »

Hy,
I'm using Ds2413 one wire ic to control the many gpios.It was worked well with Arduino.But I wish to implement project with STM32,is there any library for stm32?
dannyf
Posts: 447
Joined: Sat Jul 04, 2020 7:46 pm

Re: Library for ds2413

Post by dannyf »

they aren't that difficult to build:
1. start with routines that transmit "1" and "0";
2. build routines that transmit bytes, using the routines above;
3. build routines that transmit commands and data, using the routines above.

#1 and #2 are physical layers and #3 is the logic layer. the key is that those routines are fairly slow so you want to use interrupt, or creative use of other hardware modules, like the spi or uart, for those purpose.
Naveen
Posts: 3
Joined: Sat Aug 08, 2020 10:52 am

Re: Library for ds2413

Post by Naveen »

Hy,
Sorry I can't understand what you told. can you explain little more detail. I saw onewireSTM library in github.is this library working for that IC.
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: Library for ds2413

Post by mrburnette »

Naveen wrote: Sat Aug 08, 2020 10:54 am Hy,
I'm using Ds2413 one wire ic to control the many gpios.It was worked well with Arduino.But I wish to implement project with STM32,is there any library for stm32?
The latest Adafruit library may work as-is, if required porting should be very easy:
https://github.com/adafruit/Adafruit_Le ... uit_DS2413
Naveen
Posts: 3
Joined: Sat Aug 08, 2020 10:52 am

Re: Library for ds2413

Post by Naveen »

I modified the code from Adafruit.But always i got no address found.But the two libraries are same.

Code: Select all

#include <OneWireSTM.h>
OneWire net(PA12);
uint8_t address[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
void setup(void) {
  Serial.begin(9600);
}

void loop(void) {
  byte i;
  byte present = 0;
  byte addr[8];

  if (!net.search(address)) {
    Serial.print("No more addresses.\n");
    net.reset_search();
    delay(250);
    return;
  }
  Serial.println("");
  Serial.print("R=");
  for ( i = 0; i < 8; i++) {
    Serial.print(address[i], HEX);
    Serial.print(" ");
  }
  if (OneWire::crc8(address, 7) != address[7]) {
    Serial.print("CRC is not valid!\n");
    return;
  }
  if (addr[0] != 0x3A) {
    Serial.print(" is not a DS2413.\n");
    return;
  }
}
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: Library for ds2413

Post by stevestrong »

Use another pin, because PA11/PA12 are reserved for USB.
Post Reply

Return to “General discussion”