I am looking for a 1 ONE PIN COMMUNICATION between ATtiny45 and STM32duino.
Task of ATtiny
1.) SLEEP (7μA),
2.) Standby mode ; sleep after 5 minutes (wake up at Int0 LOW),
3.) Battery voltage control / charge control / stm32 & devices power control.
Now I have a pin free to communicate with the STM32F103C8.
Protocol-Question:
STM > ATtiny: battery voltage ? ATtiny > STM : voltage [3300]
Protocol-Command:
STM > ATtiny: stanabdy ! (ATtiny sleep until wake up at Int0 LOW)
STM > ATtiny: sleep ! (ATtiny sleep ; until reset by USB plug in)
STM > ATtiny: Reset Standby Counter (Power Saving Mode)
ATtiny > STM: Battery to LOW
ATtiny > STM: will turn off
Communication slowly and rarely (every 4 minutes Standby mode reset)
The same pin must receive and send. But only receive and then send answer.
Which is not possible: SoftSerialIntAP
; SoftSerialIntCC
; SoftwareSeriesSTM32 (48MHz USB)
SoftwareUart and SoftwareSerialWithHalfDuplex
Has anyone ever set up such a communication ? (Google is silent on the subject.)
It does not matter if serial, one wire, manchester & Co. It should work the same for both (ATtiny/STM32).
vy 73 Andreas
I think there is a OneWire master library for STM32 but not a slave library.
However I think AVR has both a master and slave library
You could try using that. But it uses pull-ups I think, so may not be designed for low power use
thank you for your feedback.
I decided to use OnWire. A library of OneWireHub (DS2438) I rewrote my needs.
Now I have -> 8Bit command, 16Bit temperature, 16Bit voltage, 16Bit counter.
Currently I’m testing, I still make a documentary and try to do this show here.
vy 73 Andreas
Request for help for my project.
I have established a communication between Atmel 328 (Master) and ATtiny (Slave) that works well. Protocol is almost OneWire (without Ardesse and pauses between each character). Without interrupt, with a timer, enough memory for the remaining tasks of ATtiny.
Implementing the 1-Wire protocol http://www.technoblogy.com/show?1LJD
… using an open-collector or open-drain output. …. , but fortunately you can achieve the same effect by programming the pin low:
PORTB = PORTB & ~(1<<OneWirePin);
The two states are then achieved by switching it between input and output. I’ve provided routines that do this called PinLow and PinRelease:
inline void PinLow () { DDRB = DDRB | 1<<OneWirePin; }
After many tests, variations and setbacks, I picked out a variant (for me) that works well with ATMEL & PIC and STM. I only write important functions; the remainder should be programmed with oscilloscope observing (so no guarantee that this is good for “beginners”.)
Again briefly to the description of the function:
(any) single – pin communication without interrupt and “bells and whistles”.
Send a byte or receive a byte (or more) without consuming much memory.
Requirement: Pin must be held with a resistor (4.7K) to VDD. [Like a OneWire.]
Description for ATMEL (Attiny45):
boolean OWC_reset = false;
boolean OWC_command = false;
boolean owc_Read = false ;
uint32_t firstMicros, calcMicros, guardDog ;
boolean bark = false;
uint8_t command, control = 0;
uint8_t DataBytes[8] = { 0,1,2,3,4,5,6,7 };
#define OneWireCommandPin PB4
inline void PinOutputLOW() { DDRB = DDRB | (1 << OneWireCommandPin); } // outputLOW
inline void PinInput() { DDRB = DDRB & ~(1 << OneWireCommandPin); } // input
inline uint8_t PinRead() { return PINB >> OneWireCommandPin & 1; } // returns 0 or 1
void setup() { OneWireSetup(); }
please check on occasion: ( with oscilloscope please !)
void loop() { pinMode(PA8,OUTPUT); digitalWrite(PA8,HIGH); delayMicroseconds(1); digitalWrite(PA8,LOW); delayMicroseconds(1); }
OR/AND
void loop() { pinMode(PA8,OUTPUT); digitalWrite(PA8,HIGH); delayMicroseconds(1); digitalWrite(PA8,LOW); delayMicroseconds(1); pinMode(PA8,INPUT); delayMicroseconds(1); }
Please vary the microseconds (1-511) and write down in a table how long your STM32 needs for something.
Now expand your test program : add SERIAL or I2C or SPI or maybe all together. And look up whatever you wrote in the first table.
Maybe another one: try to choose a different board. There are some STM32F103 who have. (NUCLEO, MAPLE & Co.)
Uuuuups does not fit anymore ? Oh yeah. 5 weeks, 2 to 3 Hours per day >> test, try, vary, change and start all over again.
( I am a system engineer, here I know myself ! (Mostly) I only say something when I’m convinced. So I tried it, it happened to me like this and it is repeatable. I am too a (old) high frequency Engineer. In electronics, we are compared with magicians/sorcerers. From immemorial time, I have to prove anything, it is not enough if it works. I too make mistakes, but to learn from these, so I’m not infallible.)
[ Excuse my English. German is my language. I hope in the English understandable.]

