Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.arch.embedded > #31841 > unrolled thread

UART connection between ATSAMD20 and ATtiny4313

Started bypozz <pozzugno@gmail.com>
First post2023-04-26 16:56 +0200
Last post2023-05-05 11:02 +0200
Articles 20 on this page of 69 — 8 participants

Back to article view | Back to comp.arch.embedded


Contents

  UART connection between ATSAMD20 and ATtiny4313 pozz <pozzugno@gmail.com> - 2023-04-26 16:56 +0200
    Re: UART connection between ATSAMD20 and ATtiny4313 David Brown <david.brown@hesbynett.no> - 2023-04-26 17:57 +0200
      Re: UART connection between ATSAMD20 and ATtiny4313 pozz <pozzugno@gmail.com> - 2023-04-26 22:40 +0200
        Re: UART connection between ATSAMD20 and ATtiny4313 Grant Edwards <invalid@invalid.invalid> - 2023-04-26 21:00 +0000
          Re: UART connection between ATSAMD20 and ATtiny4313 Rick C <gnuarm.deletethisbit@gmail.com> - 2023-04-26 17:20 -0700
          Re: UART connection between ATSAMD20 and ATtiny4313 pozz <pozzugno@gmail.com> - 2023-04-27 10:15 +0200
    Re: UART connection between ATSAMD20 and ATtiny4313 Rick C <gnuarm.deletethisbit@gmail.com> - 2023-04-26 09:26 -0700
      Re: UART connection between ATSAMD20 and ATtiny4313 pozz <pozzugno@gmail.com> - 2023-04-26 22:44 +0200
        Re: UART connection between ATSAMD20 and ATtiny4313 Rick C <gnuarm.deletethisbit@gmail.com> - 2023-04-26 17:10 -0700
          Re: UART connection between ATSAMD20 and ATtiny4313 David Brown <david.brown@hesbynett.no> - 2023-04-27 09:17 +0200
          Re: UART connection between ATSAMD20 and ATtiny4313 pozz <pozzugno@gmail.com> - 2023-04-27 10:28 +0200
            Re: UART connection between ATSAMD20 and ATtiny4313 Andrew Smallshaw <andrews@sdf.org> - 2023-04-27 13:28 +0000
              Re: UART connection between ATSAMD20 and ATtiny4313 Rick C <gnuarm.deletethisbit@gmail.com> - 2023-04-27 09:22 -0700
                Re: UART connection between ATSAMD20 and ATtiny4313 David Brown <david.brown@hesbynett.no> - 2023-04-28 09:48 +0200
                  Re: UART connection between ATSAMD20 and ATtiny4313 Rick C <gnuarm.deletethisbit@gmail.com> - 2023-04-28 01:55 -0700
              Re: UART connection between ATSAMD20 and ATtiny4313 Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2023-04-27 20:18 +0300
                Re: UART connection between ATSAMD20 and ATtiny4313 Ulf Samuelsson <ulf.r.samuelsson@gmail.com> - 2023-04-27 23:03 +0200
                  Re: UART connection between ATSAMD20 and ATtiny4313 Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2023-04-28 09:58 +0300
                Re: UART connection between ATSAMD20 and ATtiny4313 Rick C <gnuarm.deletethisbit@gmail.com> - 2023-04-27 17:45 -0700
                  Re: UART connection between ATSAMD20 and ATtiny4313 Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2023-04-28 10:00 +0300
                    Re: UART connection between ATSAMD20 and ATtiny4313 Rick C <gnuarm.deletethisbit@gmail.com> - 2023-04-28 00:21 -0700
                      Re: UART connection between ATSAMD20 and ATtiny4313 Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2023-04-28 11:43 +0300
                        Re: UART connection between ATSAMD20 and ATtiny4313 Ulf Samuelsson <ulf.r.samuelsson@gmail.com> - 2023-04-28 11:10 +0200
                          Re: UART connection between ATSAMD20 and ATtiny4313 Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2023-04-28 17:26 +0300
                        Re: UART connection between ATSAMD20 and ATtiny4313 Rick C <gnuarm.deletethisbit@gmail.com> - 2023-04-28 02:14 -0700
                          Re: UART connection between ATSAMD20 and ATtiny4313 Rick C <gnuarm.deletethisbit@gmail.com> - 2023-04-28 02:19 -0700
                  Re: UART connection between ATSAMD20 and ATtiny4313 David Brown <david.brown@hesbynett.no> - 2023-04-28 14:51 +0200
                    Re: UART connection between ATSAMD20 and ATtiny4313 Rick C <gnuarm.deletethisbit@gmail.com> - 2023-04-28 16:41 -0700
                      Re: UART connection between ATSAMD20 and ATtiny4313 David Brown <david.brown@hesbynett.no> - 2023-04-29 18:01 +0200
                        Re: UART connection between ATSAMD20 and ATtiny4313 Rick C <gnuarm.deletethisbit@gmail.com> - 2023-04-30 02:37 -0700
            Re: UART connection between ATSAMD20 and ATtiny4313 Rick C <gnuarm.deletethisbit@gmail.com> - 2023-04-27 09:02 -0700
              Re: UART connection between ATSAMD20 and ATtiny4313 David Brown <david.brown@hesbynett.no> - 2023-04-28 15:01 +0200
                Re: UART connection between ATSAMD20 and ATtiny4313 Rick C <gnuarm.deletethisbit@gmail.com> - 2023-04-28 16:44 -0700
                  Re: UART connection between ATSAMD20 and ATtiny4313 David Brown <david.brown@hesbynett.no> - 2023-04-29 17:59 +0200
    Re: UART connection between ATSAMD20 and ATtiny4313 pozz <pozzugno@gmail.com> - 2023-05-03 18:16 +0200
      Re: UART connection between ATSAMD20 and ATtiny4313 Rick C <gnuarm.deletethisbit@gmail.com> - 2023-05-03 09:40 -0700
        Re: UART connection between ATSAMD20 and ATtiny4313 pozz <pozzugno@gmail.com> - 2023-05-04 10:34 +0200
          Re: UART connection between ATSAMD20 and ATtiny4313 David Brown <david.brown@hesbynett.no> - 2023-05-04 12:31 +0200
            Re: UART connection between ATSAMD20 and ATtiny4313 pozz <pozzugno@gmail.com> - 2023-05-05 10:51 +0200
              Re: UART connection between ATSAMD20 and ATtiny4313 David Brown <david.brown@hesbynett.no> - 2023-05-05 12:59 +0200
                Re: UART connection between ATSAMD20 and ATtiny4313 pozz <pozzugno@gmail.com> - 2023-05-05 18:01 +0200
                  Re: UART connection between ATSAMD20 and ATtiny4313 Dimiter_Popoff <dp@tgi-sci.com> - 2023-05-05 19:52 +0300
                    Re: UART connection between ATSAMD20 and ATtiny4313 pozz <pozzugno@gmail.com> - 2023-05-07 23:20 +0200
                  Re: UART connection between ATSAMD20 and ATtiny4313 Rick C <gnuarm.deletethisbit@gmail.com> - 2023-05-05 11:37 -0700
                    Re: UART connection between ATSAMD20 and ATtiny4313 pozz <pozzugno@gmail.com> - 2023-05-07 23:21 +0200
                      Re: UART connection between ATSAMD20 and ATtiny4313 David Brown <david.brown@hesbynett.no> - 2023-05-08 08:37 +0200
                        Re: UART connection between ATSAMD20 and ATtiny4313 pozz <pozzugno@gmail.com> - 2023-05-08 09:24 +0200
              Re: UART connection between ATSAMD20 and ATtiny4313 Grant Edwards <invalid@invalid.invalid> - 2023-05-05 20:16 +0000
                Re: UART connection between ATSAMD20 and ATtiny4313 pozz <pozzugno@gmail.com> - 2023-05-07 23:17 +0200
                  Re: UART connection between ATSAMD20 and ATtiny4313 Rick C <gnuarm.deletethisbit@gmail.com> - 2023-05-07 14:27 -0700
                    Re: UART connection between ATSAMD20 and ATtiny4313 David Brown <david.brown@hesbynett.no> - 2023-05-08 08:34 +0200
                      Re: UART connection between ATSAMD20 and ATtiny4313 Dimiter_Popoff <dp@tgi-sci.com> - 2023-05-08 13:46 +0300
                    Re: UART connection between ATSAMD20 and ATtiny4313 pozz <pozzugno@gmail.com> - 2023-05-08 09:38 +0200
                      Re: UART connection between ATSAMD20 and ATtiny4313 Grant Edwards <invalid@invalid.invalid> - 2023-05-08 14:12 +0000
                        Re: UART connection between ATSAMD20 and ATtiny4313 pozz <pozzugno@gmail.com> - 2023-05-08 18:13 +0200
                          Re: UART connection between ATSAMD20 and ATtiny4313 Rick C <gnuarm.deletethisbit@gmail.com> - 2023-05-08 11:39 -0700
                            Re: UART connection between ATSAMD20 and ATtiny4313 pozz <pozzugno@gmail.com> - 2023-05-09 17:04 +0200
                              Re: UART connection between ATSAMD20 and ATtiny4313 Rick C <gnuarm.deletethisbit@gmail.com> - 2023-05-09 14:32 -0700
                                Re: UART connection between ATSAMD20 and ATtiny4313 pozz <pozzugno@gmail.com> - 2023-05-10 08:55 +0200
                          Re: UART connection between ATSAMD20 and ATtiny4313 Grant Edwards <invalid@invalid.invalid> - 2023-05-08 19:09 +0000
                            Re: UART connection between ATSAMD20 and ATtiny4313 pozz <pozzugno@gmail.com> - 2023-05-09 17:08 +0200
                      Re: UART connection between ATSAMD20 and ATtiny4313 Rick C <gnuarm.deletethisbit@gmail.com> - 2023-05-08 07:32 -0700
                        Re: UART connection between ATSAMD20 and ATtiny4313 pozz <pozzugno@gmail.com> - 2023-05-08 18:27 +0200
                          Re: UART connection between ATSAMD20 and ATtiny4313 Rick C <gnuarm.deletethisbit@gmail.com> - 2023-05-08 11:52 -0700
                            Re: UART connection between ATSAMD20 and ATtiny4313 pozz <pozzugno@gmail.com> - 2023-05-09 16:52 +0200
                              Re: UART connection between ATSAMD20 and ATtiny4313 Grant Edwards <invalid@invalid.invalid> - 2023-05-09 15:10 +0000
                              Re: UART connection between ATSAMD20 and ATtiny4313 Rick C <gnuarm.deletethisbit@gmail.com> - 2023-05-09 14:29 -0700
          Re: UART connection between ATSAMD20 and ATtiny4313 Rick C <gnuarm.deletethisbit@gmail.com> - 2023-05-04 06:21 -0700
            Re: UART connection between ATSAMD20 and ATtiny4313 pozz <pozzugno@gmail.com> - 2023-05-05 11:02 +0200

Page 1 of 4  [1] 2 3 4  Next page →


#31841 — UART connection between ATSAMD20 and ATtiny4313

Frompozz <pozzugno@gmail.com>
Date2023-04-26 16:56 +0200
SubjectUART connection between ATSAMD20 and ATtiny4313
Message-ID<u2be3n$1a5nq$1@dont-email.me>
I'd like to use async UART to let these MCUs communicate.
The protocol will be request-response with the request generated by the 
SAM MCU. The baudrate will be 38400bps.

I'd like to use internal oscillator of ATtiny4313, while the SAM will 
use an external 32.768kHz crystal (that is multiplied by internal PLL to 
reach 48MHz).

I'm not sure if this scenario can work well. My concerns are related to 
the internal oscillator of ATtiny4313 that hasn't a good accuracy over 
temperature and life.

The tiny MCU will be supplied by 3.3V and its temperature will be in the 
range 0-80°C.

[toc] | [next] | [standalone]


#31842

FromDavid Brown <david.brown@hesbynett.no>
Date2023-04-26 17:57 +0200
Message-ID<u2bhl1$1em9g$1@dont-email.me>
In reply to#31841
On 26/04/2023 16:56, pozz wrote:
> I'd like to use async UART to let these MCUs communicate.
> The protocol will be request-response with the request generated by the 
> SAM MCU. The baudrate will be 38400bps.
> 
> I'd like to use internal oscillator of ATtiny4313, while the SAM will 
> use an external 32.768kHz crystal (that is multiplied by internal PLL to 
> reach 48MHz).
> 
> I'm not sure if this scenario can work well. My concerns are related to 
> the internal oscillator of ATtiny4313 that hasn't a good accuracy over 
> temperature and life.
> 
> The tiny MCU will be supplied by 3.3V and its temperature will be in the 
> range 0-80°C.

The rule of thumb is a maximum of 5% total mismatch in baud rates 
between the two sides.  One side has a crystal and PLL, so it will be 
quite close - that means you can have most of the error margin on the 
other side.  If the internal oscillator is within 2%, you should be 
fine.  If it is 5% or more, you will want to do some automatic 
measurement of the rate.

[toc] | [prev] | [next] | [standalone]


#31844

Frompozz <pozzugno@gmail.com>
Date2023-04-26 22:40 +0200
Message-ID<u2c27u$1hfgr$1@dont-email.me>
In reply to#31842
Il 26/04/2023 17:57, David Brown ha scritto:
> On 26/04/2023 16:56, pozz wrote:
>> I'd like to use async UART to let these MCUs communicate.
>> The protocol will be request-response with the request generated by 
>> the SAM MCU. The baudrate will be 38400bps.
>>
>> I'd like to use internal oscillator of ATtiny4313, while the SAM will 
>> use an external 32.768kHz crystal (that is multiplied by internal PLL 
>> to reach 48MHz).
>>
>> I'm not sure if this scenario can work well. My concerns are related 
>> to the internal oscillator of ATtiny4313 that hasn't a good accuracy 
>> over temperature and life.
>>
>> The tiny MCU will be supplied by 3.3V and its temperature will be in 
>> the range 0-80°C.
> 
> The rule of thumb is a maximum of 5% total mismatch in baud rates 
> between the two sides.  One side has a crystal and PLL, so it will be 
> quite close - that means you can have most of the error margin on the 
> other side.  If the internal oscillator is within 2%, you should be 
> fine.  If it is 5% or more, you will want to do some automatic 
> measurement of the rate.
> 

ATtiny4313 datasheet[1] says the internal oscillator is factory 
calibrated with an accuracy of +/-10% at Vcc=3V and 25°C temperature. 
This accuracy can be reduced to +/-2% at a fixed voltage and a fixed 
temperature with a user calibration.

I could calibrate for a fixed voltage (3.3V), but I can't fix a 
temperature, because it can vary in the real application.

I tried to heat the ATtiny4313 with a heat gun and the communication 
between SAM and tiny didn't stopped, but I know this isn't an exaustive 
test.


[1] https://ww1.microchip.com/downloads/en/DeviceDoc/doc8246.pdf

[toc] | [prev] | [next] | [standalone]


#31846

FromGrant Edwards <invalid@invalid.invalid>
Date2023-04-26 21:00 +0000
Message-ID<u2c3d0$l35$1@reader2.panix.com>
In reply to#31844
On 2023-04-26, pozz <pozzugno@gmail.com> wrote:

> ATtiny4313 datasheet[1] says the internal oscillator is factory 
> calibrated with an accuracy of +/-10% at Vcc=3V and 25°C temperature.

10% total error (combination of both ends) is pretty much right at the
limit according to the usual rule of thumb for UART receivers that
sync only on the start bit. IIRC, there used to be UART receivers that
would sync on every edge within the data "word" as well, but I don't
think that was ever very common -- and to take advantage of it, you
had to make sure your data had edges. :)

Can you spare a line for a clock and go synchronous? (Or are they
really UARTs and not USARTs?).

> This accuracy can be reduced to +/-2% at a fixed voltage and a fixed 
> temperature with a user calibration.

2% is no problem at all. With a crystal on the other end, you should
be able to easily tolerate +/-5%. The requirement for a fixed
temperature, OTOH, is usually a problem.

> I could calibrate for a fixed voltage (3.3V), but I can't fix a 
> temperature, because it can vary in the real application.

Does the ATtiny have an on-die temp sensor? If yes, you could try
characterizing the oscillator over temperature at 3.3V and adjusting
the baud rate divisor as the temperature changes. That get's expensive
if you have to do it on every unit during production, but if the T/F
curve is consistent enough between units, then maybe...

[toc] | [prev] | [next] | [standalone]


#31848

FromRick C <gnuarm.deletethisbit@gmail.com>
Date2023-04-26 17:20 -0700
Message-ID<8fc93140-1821-4fc4-b848-6ec9a6b559ean@googlegroups.com>
In reply to#31846
On Wednesday, April 26, 2023 at 5:00:22 PM UTC-4, Grant Edwards wrote:
> On 2023-04-26, pozz <pozz...@gmail.com> wrote: 
> 
> > ATtiny4313 datasheet[1] says the internal oscillator is factory 
> > calibrated with an accuracy of +/-10% at Vcc=3V and 25°C temperature.
> 10% total error (combination of both ends) is pretty much right at the 
> limit according to the usual rule of thumb for UART receivers that 
> sync only on the start bit. 

I think you are not doing the calculation right.  The limit is based on the UART trying to sample in the middle of a bit.  If it gets out by a half a bit time, either way, it will sample the wrong bit.  With 10 bits in the character, including start and stop bits, that puts the total error limit at about 5%.  This is actually closer to 5.5% (because while it is 10 bits, it's only 9 bit times between start and stop bits), but then you need to subtract a fraction of a bit for the internal Nx clock used to sample the bit stream.  So round off to 5%. That's the total error allowed, including both ends.  Then there's distortion in the pulse edges.  With 26 us bit times, there may be issues with asymmetric edge distortion.  There has been no mention of the electrical interface. 


> IIRC, there used to be UART receivers that 
> would sync on every edge within the data "word" as well, but I don't 
> think that was ever very common -- and to take advantage of it, you 
> had to make sure your data had edges. :) 
> 
> Can you spare a line for a clock and go synchronous? (Or are they 
> really UARTs and not USARTs?).
> > This accuracy can be reduced to +/-2% at a fixed voltage and a fixed 
> > temperature with a user calibration.
> 2% is no problem at all. With a crystal on the other end, you should 
> be able to easily tolerate +/-5%. The requirement for a fixed 
> temperature, OTOH, is usually a problem.
> > I could calibrate for a fixed voltage (3.3V), but I can't fix a 
> > temperature, because it can vary in the real application.
> Does the ATtiny have an on-die temp sensor? If yes, you could try 
> characterizing the oscillator over temperature at 3.3V and adjusting 
> the baud rate divisor as the temperature changes. That get's expensive 
> if you have to do it on every unit during production, but if the T/F 
> curve is consistent enough between units, then maybe...

Calibration, in general is expensive.  But yes, a calibration curve is worse, since you need to wait for temperature to adjust.  

-- 

  Rick C.

  -- Get 1,000 miles of free Supercharging
  -- Tesla referral code - https://ts.la/richard11209

[toc] | [prev] | [next] | [standalone]


#31850

Frompozz <pozzugno@gmail.com>
Date2023-04-27 10:15 +0200
Message-ID<u2dav8$1q74u$1@dont-email.me>
In reply to#31846
Il 26/04/2023 23:00, Grant Edwards ha scritto:
> On 2023-04-26, pozz <pozzugno@gmail.com> wrote:
> 
>> ATtiny4313 datasheet[1] says the internal oscillator is factory
>> calibrated with an accuracy of +/-10% at Vcc=3V and 25°C temperature.
> 
> 10% total error (combination of both ends) is pretty much right at the
> limit according to the usual rule of thumb for UART receivers that
> sync only on the start bit. IIRC, there used to be UART receivers that
> would sync on every edge within the data "word" as well, but I don't
> think that was ever very common -- and to take advantage of it, you
> had to make sure your data had edges. :)
> 
> Can you spare a line for a clock and go synchronous? (Or are they
> really UARTs and not USARTs?).

No, I can't. The MCUs are not on the same board and they are really 
connected through RS485 half-duplex transceivers.


>> This accuracy can be reduced to +/-2% at a fixed voltage and a fixed
>> temperature with a user calibration.
> 
> 2% is no problem at all. With a crystal on the other end, you should
> be able to easily tolerate +/-5%. The requirement for a fixed
> temperature, OTOH, is usually a problem.
> 
>> I could calibrate for a fixed voltage (3.3V), but I can't fix a
>> temperature, because it can vary in the real application.
> 
> Does the ATtiny have an on-die temp sensor? If yes, you could try
> characterizing the oscillator over temperature at 3.3V and adjusting
> the baud rate divisor as the temperature changes. That get's expensive
> if you have to do it on every unit during production, but if the T/F
> curve is consistent enough between units, then maybe...

Thank you for this suggestion, but I can't use this trick.

[toc] | [prev] | [next] | [standalone]


#31843

FromRick C <gnuarm.deletethisbit@gmail.com>
Date2023-04-26 09:26 -0700
Message-ID<8c53b82a-f075-4b51-98bd-792221acbe60n@googlegroups.com>
In reply to#31841
On Wednesday, April 26, 2023 at 10:57:01 AM UTC-4, pozz wrote:
> I'd like to use async UART to let these MCUs communicate. 
> The protocol will be request-response with the request generated by the 
> SAM MCU. The baudrate will be 38400bps. 
> 
> I'd like to use internal oscillator of ATtiny4313, while the SAM will 
> use an external 32.768kHz crystal (that is multiplied by internal PLL to 
> reach 48MHz). 
> 
> I'm not sure if this scenario can work well. My concerns are related to 
> the internal oscillator of ATtiny4313 that hasn't a good accuracy over 
> temperature and life. 
> 
> The tiny MCU will be supplied by 3.3V and its temperature will be in the 
> range 0-80°C.

I don't get what your question is.  You seem to understand the concepts.  You don't tell us the relevant data however.  What does the data sheet say about the frequency variability of the internal clock over PVT (process, voltage and temperature)?  I assume you are aware that the 3.3V supply will have an accuracy and an RC clock rate can be voltage dependent.  It depends on how they designed the circuit.  There are techniques for removing most of the voltage dependency, if they used them. 

You can always use the bit times of the SAM to adjust the bit rate on the ATtiny.  That used to be part of the protocol for low data rate modems.  The first characters sent were AT if I recall, which give good edges to time to measure the bit rate.  At 38400 bps this might be a bit tricker, it depends on your instruction rate.  A bit time is just 26 us.  Will this be a software UART, or a hardware unit? 

-- 

  Rick C.

  - Get 1,000 miles of free Supercharging
  - Tesla referral code - https://ts.la/richard11209

[toc] | [prev] | [next] | [standalone]


#31845

Frompozz <pozzugno@gmail.com>
Date2023-04-26 22:44 +0200
Message-ID<u2c2eu$1hfgr$2@dont-email.me>
In reply to#31843
Il 26/04/2023 18:26, Rick C ha scritto:
> On Wednesday, April 26, 2023 at 10:57:01 AM UTC-4, pozz wrote:
>> I'd like to use async UART to let these MCUs communicate.
>> The protocol will be request-response with the request generated by the
>> SAM MCU. The baudrate will be 38400bps.
>>
>> I'd like to use internal oscillator of ATtiny4313, while the SAM will
>> use an external 32.768kHz crystal (that is multiplied by internal PLL to
>> reach 48MHz).
>>
>> I'm not sure if this scenario can work well. My concerns are related to
>> the internal oscillator of ATtiny4313 that hasn't a good accuracy over
>> temperature and life.
>>
>> The tiny MCU will be supplied by 3.3V and its temperature will be in the
>> range 0-80°C.
> 
> I don't get what your question is.  You seem to understand the concepts.  You don't tell us the relevant data however.  What does the data sheet say about the frequency variability of the internal clock over PVT (process, voltage and temperature)?  I assume you are aware that the 3.3V supply will have an accuracy and an RC clock rate can be voltage dependent.  It depends on how they designed the circuit.  There are techniques for removing most of the voltage dependency, if they used them.

ATtiny4313 datasheet[1] says the internal oscillator is factory 
calibrated with an accuracy of ±10% at Vcc=3V and 25°C temperature. This 
accuracy can be reduced to ±2% at a fixed voltage and a fixed 
temperature with a user calibration.

> 
> You can always use the bit times of the SAM to adjust the bit rate on the ATtiny.  That used to be part of the protocol for low data rate modems.  The first characters sent were AT if I recall, which give good edges to time to measure the bit rate.  At 38400 bps this might be a bit tricker, it depends on your instruction rate.  A bit time is just 26 us.  Will this be a software UART, or a hardware unit?
> 

I will use the interal UART peripheral of ATtiny4313. I can't add too 
much code, the Flash memory is almost full. I wanted to know if the 
figures shown on the datasheet guarantee good communication between the 
the MCUs. It seems this isn't the case.


[1] https://ww1.microchip.com/downloads/en/DeviceDoc/doc8246.pdf

[toc] | [prev] | [next] | [standalone]


#31847

FromRick C <gnuarm.deletethisbit@gmail.com>
Date2023-04-26 17:10 -0700
Message-ID<3400c428-350a-4826-adc8-df2c6105fc8bn@googlegroups.com>
In reply to#31845
On Wednesday, April 26, 2023 at 4:44:20 PM UTC-4, pozz wrote:
> Il 26/04/2023 18:26, Rick C ha scritto: 
> > On Wednesday, April 26, 2023 at 10:57:01 AM UTC-4, pozz wrote: 
> >> I'd like to use async UART to let these MCUs communicate. 
> >> The protocol will be request-response with the request generated by the 
> >> SAM MCU. The baudrate will be 38400bps. 
> >> 
> >> I'd like to use internal oscillator of ATtiny4313, while the SAM will 
> >> use an external 32.768kHz crystal (that is multiplied by internal PLL to 
> >> reach 48MHz). 
> >> 
> >> I'm not sure if this scenario can work well. My concerns are related to 
> >> the internal oscillator of ATtiny4313 that hasn't a good accuracy over 
> >> temperature and life. 
> >> 
> >> The tiny MCU will be supplied by 3.3V and its temperature will be in the 
> >> range 0-80°C. 
> > 
> > I don't get what your question is. You seem to understand the concepts. You don't tell us the relevant data however. What does the data sheet say about the frequency variability of the internal clock over PVT (process, voltage and temperature)? I assume you are aware that the 3.3V supply will have an accuracy and an RC clock rate can be voltage dependent. It depends on how they designed the circuit. There are techniques for removing most of the voltage dependency, if they used them.
> ATtiny4313 datasheet[1] says the internal oscillator is factory
> calibrated with an accuracy of ±10% at Vcc=3V and 25°C temperature. This 
> accuracy can be reduced to ±2% at a fixed voltage and a fixed
> temperature with a user calibration. 

Ok, that is information.  Do you have a question? 


> > You can always use the bit times of the SAM to adjust the bit rate on the ATtiny. That used to be part of the protocol for low data rate modems. The first characters sent were AT if I recall, which give good edges to time to measure the bit rate. At 38400 bps this might be a bit tricker, it depends on your instruction rate. A bit time is just 26 us. Will this be a software UART, or a hardware unit? 
> >
> I will use the interal UART peripheral of ATtiny4313. I can't add too 
> much code, the Flash memory is almost full. I wanted to know if the 
> figures shown on the datasheet guarantee good communication between the 
> the MCUs. It seems this isn't the case. 
> 
> 
> [1] https://ww1.microchip.com/downloads/en/DeviceDoc/doc8246.pdf

You point me to a data sheet.  I am not reading the data sheet to do your work for you.  I'm happy to discuss the information and offer advice and opinion.  The info you provide above with the 2% stability if temperature and voltage are maintained and the clock calibrated, is not enough to know if this will work. 

When you write, "It seems this isn't the case.", what do you base this on?  What is your reasoning? 

I don't think the software UART is a lot of code, but you don't need that.  You need to write a routine to measure a bit time on the input to calibrate your clock to the incoming bit times.  That should not be a lot of code.  Translating a loop count into a bit clock setting for the UART should be a simple linear relationship, although it may involve a divide. You only need to work over a small range, so a small table lookup should be pretty close to optimal solution. 

I don't see where you have a choice, unless you want to add a crystal to the ATtiny. Can the SAM chip send a clock?  You can use an SPI port instead of a UART, or just send a clock to use for the bit rate clock in the UART?  

-- 

  Rick C.

  + Get 1,000 miles of free Supercharging
  + Tesla referral code - https://ts.la/richard11209

[toc] | [prev] | [next] | [standalone]


#31849

FromDavid Brown <david.brown@hesbynett.no>
Date2023-04-27 09:17 +0200
Message-ID<u2d7ih$1qmgf$1@dont-email.me>
In reply to#31847
On 27/04/2023 02:10, Rick C wrote:

> I don't think the software UART is a lot of code, but you don't need
> that.  You need to write a routine to measure a bit time on the input
> to calibrate your clock to the incoming bit times.  That should not
> be a lot of code.  Translating a loop count into a bit clock setting
> for the UART should be a simple linear relationship, although it may
> involve a divide. You only need to work over a small range, so a
> small table lookup should be pretty close to optimal solution.
> 

That's definitely one way to do it, yes.

Have the master side send a couple of 0x00 bytes before the data, and 
use an interrupt on the Rx pin falling edge - when that comes in, count 
the time until a rising edge is seen.  If that time works out to within 
10% of the nominal expected time, you are calibrated and can turn off 
the interrupt.  Alternatively, send 0x55 bytes first and measure 
multiple short periods.  There will be some details to work out, 
depending on the what you are sending, the type of noise you expect, how 
often you need to re-calibrate, etc.  You are making a software 
equivalent to a PLL.

There's no need for a lookup table here (unless I've got my calculations 
upside down!).  The more cycles you count for the incoming trainer 
characters, the bigger the UART divider value you need.  That means your 
divisions will be done with constant values, and the compiler will turn 
those into multiplies.



An alternative is trial and error.  If your clock source is ±10%, and 
you need to get within ±2%, start your UART at the nominally correct 
baud rate.  If you don't receive error-free telegrams within a timeout, 
go 2% faster.  Keep adding 2%, stepping from +10% to -10%, until you hit 
a baud rate that works.

You can get even fancier here by figuring out the lowest and highest 
rates that work, then picking their average to get the best value.

[toc] | [prev] | [next] | [standalone]


#31851

Frompozz <pozzugno@gmail.com>
Date2023-04-27 10:28 +0200
Message-ID<u2dbn7$1q74v$1@dont-email.me>
In reply to#31847
Il 27/04/2023 02:10, Rick C ha scritto:
> On Wednesday, April 26, 2023 at 4:44:20 PM UTC-4, pozz wrote:
>> Il 26/04/2023 18:26, Rick C ha scritto:
>>> On Wednesday, April 26, 2023 at 10:57:01 AM UTC-4, pozz wrote:
>>>> I'd like to use async UART to let these MCUs communicate.
>>>> The protocol will be request-response with the request generated by the
>>>> SAM MCU. The baudrate will be 38400bps.
>>>>
>>>> I'd like to use internal oscillator of ATtiny4313, while the SAM will
>>>> use an external 32.768kHz crystal (that is multiplied by internal PLL to
>>>> reach 48MHz).
>>>>
>>>> I'm not sure if this scenario can work well. My concerns are related to
>>>> the internal oscillator of ATtiny4313 that hasn't a good accuracy over
>>>> temperature and life.
>>>>
>>>> The tiny MCU will be supplied by 3.3V and its temperature will be in the
>>>> range 0-80°C.
>>>
>>> I don't get what your question is. You seem to understand the concepts. You don't tell us the relevant data however. What does the data sheet say about the frequency variability of the internal clock over PVT (process, voltage and temperature)? I assume you are aware that the 3.3V supply will have an accuracy and an RC clock rate can be voltage dependent. It depends on how they designed the circuit. There are techniques for removing most of the voltage dependency, if they used them.
>> ATtiny4313 datasheet[1] says the internal oscillator is factory
>> calibrated with an accuracy of ±10% at Vcc=3V and 25°C temperature. This
>> accuracy can be reduced to ±2% at a fixed voltage and a fixed
>> temperature with a user calibration.
> 
> Ok, that is information.  Do you have a question?
> 
> 
>>> You can always use the bit times of the SAM to adjust the bit rate on the ATtiny. That used to be part of the protocol for low data rate modems. The first characters sent were AT if I recall, which give good edges to time to measure the bit rate. At 38400 bps this might be a bit tricker, it depends on your instruction rate. A bit time is just 26 us. Will this be a software UART, or a hardware unit?
>>>
>> I will use the interal UART peripheral of ATtiny4313. I can't add too
>> much code, the Flash memory is almost full. I wanted to know if the
>> figures shown on the datasheet guarantee good communication between the
>> the MCUs. It seems this isn't the case.
>>
>>
>> [1] https://ww1.microchip.com/downloads/en/DeviceDoc/doc8246.pdf
> 
> You point me to a data sheet.  I am not reading the data sheet to do your work for you.  

And I don't want you do it if you don't want. The datasheet link is 
there if someone WANTS to look at it with a single click of the mouse.


> I'm happy to discuss the information and offer advice and opinion.  The info you provide above with the 2% stability if temperature and voltage are maintained and the clock calibrated, is not enough to know if this will work.
> 
> When you write, "It seems this isn't the case.", what do you base this on?  What is your reasoning?

Because internal oscillator has an accuracy of 10% and I read that UART 
receivers are usually able to decode the input signal with an error of 
2-5% order.

However I tested one sample at high temperature, but the MCUs continued 
communicating well.


> I don't think the software UART is a lot of code, but you don't need that.  You need to write a routine to measure a bit time on the input to calibrate your clock to the incoming bit times.  That should not be a lot of code.  Translating a loop count into a bit clock setting for the UART should be a simple linear relationship, although it may involve a divide. You only need to work over a small range, so a small table lookup should be pretty close to optimal solution.

Ok, thanks for suggestion.


> I don't see where you have a choice, unless you want to add a crystal to the ATtiny. Can the SAM chip send a clock?  You can use an SPI port instead of a UART, or just send a clock to use for the bit rate clock in the UART?

No, this isn't an option.

[toc] | [prev] | [next] | [standalone]


#31852

FromAndrew Smallshaw <andrews@sdf.org>
Date2023-04-27 13:28 +0000
Message-ID<slrnu4ku3q.qb0.andrews@sdf.org>
In reply to#31851
On 2023-04-27, pozz <pozzugno@gmail.com> wrote:
> Il 27/04/2023 02:10, Rick C ha scritto:
>
>> I don't see where you have a choice, unless you want to add a crystal to the ATtiny. Can the SAM chip send a clock?  You can use an SPI port instead of a UART, or just send a clock to use for the bit rate clock in the UART?
>
> No, this isn't an option.

The other option would be to adopt a Manchester-encoded (self
clocking) signal.  Wouldn't be true RS485 but would pass through
transceivers and cabling at sensible baud rates.  Manchester coding
is fine provided the clocks are within 2:1 of each other.  You will
need to bit-bang the interface though, the UART won't handle it.

-- 
Andrew Smallshaw
andrews@sdf.org

[toc] | [prev] | [next] | [standalone]


#31854

FromRick C <gnuarm.deletethisbit@gmail.com>
Date2023-04-27 09:22 -0700
Message-ID<fbdc8ee3-eaa9-4042-b4ca-d86f482f9d2dn@googlegroups.com>
In reply to#31852
On Thursday, April 27, 2023 at 9:28:33 AM UTC-4, Andrew Smallshaw wrote:
> On 2023-04-27, pozz <pozz...@gmail.com> wrote: 
> > Il 27/04/2023 02:10, Rick C ha scritto: 
> > 
> >> I don't see where you have a choice, unless you want to add a crystal to the ATtiny. Can the SAM chip send a clock? You can use an SPI port instead of a UART, or just send a clock to use for the bit rate clock in the UART? 
> > 
> > No, this isn't an option.
> The other option would be to adopt a Manchester-encoded (self 
> clocking) signal. Wouldn't be true RS485 but would pass through 
> transceivers and cabling at sensible baud rates. Manchester coding 
> is fine provided the clocks are within 2:1 of each other. You will 
> need to bit-bang the interface though, the UART won't handle it. 

What about Manchester encoding is not RS-485?  That's just an electrical interface standard, no? 

But that is a great idea... if the hardware will accommodate it.  Or this can be done in the UART using a faster clock and synchronous mode.  Send characters with one data bit per character, the Manchester encoded bit, x0F or xF0.  It would not be terribly hard to decode the data in software.. possibly.  I believe you align to the transition that is always present mid-cell, then look for the presence/absence of the other transition.  The OP talked about the "small" processor being program space constrained, but again, this is not a lot of code... maybe.  So maybe this will be too much.  But it would solve the clocking issue.  Then again, so would a crystal. 

-- 

  Rick C.

  +- Get 1,000 miles of free Supercharging
  +- Tesla referral code - https://ts.la/richard11209

[toc] | [prev] | [next] | [standalone]


#31877

FromDavid Brown <david.brown@hesbynett.no>
Date2023-04-28 09:48 +0200
Message-ID<u2ftob$2bnd0$5@dont-email.me>
In reply to#31854
On 27/04/2023 18:22, Rick C wrote:
> On Thursday, April 27, 2023 at 9:28:33 AM UTC-4, Andrew Smallshaw wrote:
>> On 2023-04-27, pozz <pozz...@gmail.com> wrote:
>>> Il 27/04/2023 02:10, Rick C ha scritto:
>>>
>>>> I don't see where you have a choice, unless you want to add a crystal to the ATtiny. Can the SAM chip send a clock? You can use an SPI port instead of a UART, or just send a clock to use for the bit rate clock in the UART?
>>>
>>> No, this isn't an option.
>> The other option would be to adopt a Manchester-encoded (self
>> clocking) signal. Wouldn't be true RS485 but would pass through
>> transceivers and cabling at sensible baud rates. Manchester coding
>> is fine provided the clocks are within 2:1 of each other. You will
>> need to bit-bang the interface though, the UART won't handle it.
> 
> What about Manchester encoding is not RS-485?  That's just an electrical interface standard, no?
> 

Technically, you are correct.  In reality, the term "RS-485" is usually 
used to mean "UART signalling on an RS-485 bus" - any other kind of 
signalling (such as Manchester encoding) would be specified explicitly. 
It's good to be technically accurate, but also good to consider less 
accurate common usage of terms.

> But that is a great idea... if the hardware will accommodate it.  Or
> this can be done in the UART using a faster clock and synchronous
> mode.  Send characters with one data bit per character, the
> Manchester encoded bit, x0F or xF0.  It would not be terribly hard to
> decode the data in software.. possibly.  I believe you align to the
> transition that is always present mid-cell, then look for the
> presence/absence of the other transition.  The OP talked about the
> "small" processor being program space constrained, but again, this is
> not a lot of code... maybe.  So maybe this will be too much.  But it
> would solve the clocking issue.  Then again, so would a crystal.
> 

Not all microcontroller UARTs have synchronous modes.  Receiving or 
sending Manchester encoded data with a UART is fiddly because of the 
start and stop bits of UART, so it is often done by bit-banging. 
Whether or not that suits the OP, only he can say.

[toc] | [prev] | [next] | [standalone]


#31883

FromRick C <gnuarm.deletethisbit@gmail.com>
Date2023-04-28 01:55 -0700
Message-ID<e51a8a3b-1214-40de-a362-b0c708e873d9n@googlegroups.com>
In reply to#31877
On Friday, April 28, 2023 at 3:48:32 AM UTC-4, David Brown wrote:
> On 27/04/2023 18:22, Rick C wrote: 
> > On Thursday, April 27, 2023 at 9:28:33 AM UTC-4, Andrew Smallshaw wrote: 
> >> On 2023-04-27, pozz <pozz...@gmail.com> wrote: 
> >>> Il 27/04/2023 02:10, Rick C ha scritto: 
> >>> 
> >>>> I don't see where you have a choice, unless you want to add a crystal to the ATtiny. Can the SAM chip send a clock? You can use an SPI port instead of a UART, or just send a clock to use for the bit rate clock in the UART? 
> >>> 
> >>> No, this isn't an option. 
> >> The other option would be to adopt a Manchester-encoded (self 
> >> clocking) signal. Wouldn't be true RS485 but would pass through 
> >> transceivers and cabling at sensible baud rates. Manchester coding 
> >> is fine provided the clocks are within 2:1 of each other. You will 
> >> need to bit-bang the interface though, the UART won't handle it. 
> > 
> > What about Manchester encoding is not RS-485? That's just an electrical interface standard, no? 
> >
> Technically, you are correct. In reality, the term "RS-485" is usually 
> used to mean "UART signalling on an RS-485 bus" - any other kind of 
> signalling (such as Manchester encoding) would be specified explicitly. 
> It's good to be technically accurate, but also good to consider less 
> accurate common usage of terms.

Not technically, actually.  "Wouldn't be true RS485" is a very clear statement, which happens to also be wrong, no matter how hands are waved. 


> > But that is a great idea... if the hardware will accommodate it. Or 
> > this can be done in the UART using a faster clock and synchronous 
> > mode. Send characters with one data bit per character, the 
> > Manchester encoded bit, x0F or xF0. It would not be terribly hard to 
> > decode the data in software.. possibly. I believe you align to the 
> > transition that is always present mid-cell, then look for the 
> > presence/absence of the other transition. The OP talked about the 
> > "small" processor being program space constrained, but again, this is 
> > not a lot of code... maybe. So maybe this will be too much. But it 
> > would solve the clocking issue. Then again, so would a crystal. 
> >
> Not all microcontroller UARTs have synchronous modes. 

I never said anything different. 


> Receiving or 
> sending Manchester encoded data with a UART is fiddly because of the 
> start and stop bits of UART, so it is often done by bit-banging. 
> Whether or not that suits the OP, only he can say.

It is simply not practical to send Manchester encoding with a UART... but Manchester is not the only encoding scheme that embeds a clock.  Or you can roll your own.  The point is, clock encoding with the data is a viable method of overcoming the lack of precision in the clock rate, which does not require bit banging an I/O pin.  The encoding scheme of IRIG is a real possibility.  The data bits are PWM encoded, with three values; 0.2, 0.5 and 0.8 widths for 0, 1 and a sync marker.  This would fit a UART very nicely.  With a distinction of symbols of 0.3 bit times, it can tolerate a lot more clock error than a typical async data stream with a start and stop bit on each character.  It would also be pretty easy to decode.  Align to the rising edge, and count the bits in the received data to find the falling edge.  0.1, 0.2 and 0.3 are all a zero bit.  0.4, 0.5 and 0.6 are all one bits.  0.7, 0.8 and 0.9 are all sync markers.  To prevent the UART from missing anything important, set it for 7 data bits and no parity on receive.  Then it always stops one bit early.  Then if the timing is off by 10%, you still don't lose any data.  This can be better than using a USART, actually.  It does the alignment in the hardware, making the decoding simpler.  It also includes a sync marker.  

Yeah, I think this is a much better scheme than Manchester encoding. 

-- 

  Rick C.

  --+ Get 1,000 miles of free Supercharging
  --+ Tesla referral code - https://ts.la/richard11209

[toc] | [prev] | [next] | [standalone]


#31860

FromTauno Voipio <tauno.voipio@notused.fi.invalid>
Date2023-04-27 20:18 +0300
Message-ID<u2eaq0$20si2$1@dont-email.me>
In reply to#31852
On 27.4.2023 16.28, Andrew Smallshaw wrote:
> On 2023-04-27, pozz <pozzugno@gmail.com> wrote:
>> Il 27/04/2023 02:10, Rick C ha scritto:
>>
>>> I don't see where you have a choice, unless you want to add a crystal to the ATtiny. Can the SAM chip send a clock?  You can use an SPI port instead of a UART, or just send a clock to use for the bit rate clock in the UART?
>>
>> No, this isn't an option.
> 
> The other option would be to adopt a Manchester-encoded (self
> clocking) signal.  Wouldn't be true RS485 but would pass through
> transceivers and cabling at sensible baud rates.  Manchester coding
> is fine provided the clocks are within 2:1 of each other.  You will
> need to bit-bang the interface though, the UART won't handle it.


I doubt that the ATTiny can handle Manchester coding at the requested 
bit rate, and it may be difficult for the SAM.

In 2016, I made a processor unit using AT91SAM4E for IEC H1 Manchester
coded bus at 31.25 kbit/s. The trick was to innovatively use the timer
counter units of the chip. A timer used to measure the times between
pulse edges could be used to receive and decode the incoming data, and
a timer running at half of the bit rate (15.625 kbit/s) could be used
to send the data. The receiver needed to respond to interrupts at the
incoming edge rate, and the transmitter needed to respond at the
outgoing bit rate.

-- 

-TV

[toc] | [prev] | [next] | [standalone]


#31865

FromUlf Samuelsson <ulf.r.samuelsson@gmail.com>
Date2023-04-27 23:03 +0200
Message-ID<u2enum$233k9$1@dont-email.me>
In reply to#31860
Den 2023-04-27 kl. 19:18, skrev Tauno Voipio:
> On 27.4.2023 16.28, Andrew Smallshaw wrote:
>> On 2023-04-27, pozz <pozzugno@gmail.com> wrote:
>>> Il 27/04/2023 02:10, Rick C ha scritto:
>>>
>>>> I don't see where you have a choice, unless you want to add a 
>>>> crystal to the ATtiny. Can the SAM chip send a clock?  You can use 
>>>> an SPI port instead of a UART, or just send a clock to use for the 
>>>> bit rate clock in the UART?
>>>
>>> No, this isn't an option.
>>
>> The other option would be to adopt a Manchester-encoded (self
>> clocking) signal.  Wouldn't be true RS485 but would pass through
>> transceivers and cabling at sensible baud rates.  Manchester coding
>> is fine provided the clocks are within 2:1 of each other.  You will
>> need to bit-bang the interface though, the UART won't handle it.
> 
> 
> I doubt that the ATTiny can handle Manchester coding at the requested 
> bit rate, and it may be difficult for the SAM.

Atmel implemented Manchester Coding in the SAM7 USART (My proposal)
but the SAMD20 has a "SERCOM" module without Manchester Coding.
I would look into the event system.


The tiny will have to do it in S/W.
/Ulf

> 
> In 2016, I made a processor unit using AT91SAM4E for IEC H1 Manchester
> coded bus at 31.25 kbit/s. The trick was to innovatively use the timer
> counter units of the chip. A timer used to measure the times between
> pulse edges could be used to receive and decode the incoming data, and
> a timer running at half of the bit rate (15.625 kbit/s) could be used
> to send the data. The receiver needed to respond to interrupts at the
> incoming edge rate, and the transmitter needed to respond at the
> outgoing bit rate.
> 

The SAM4E USART supports Manchester Coding in H/W.
The SAM4E UART does not.

/Ulf

[toc] | [prev] | [next] | [standalone]


#31869

FromTauno Voipio <tauno.voipio@notused.fi.invalid>
Date2023-04-28 09:58 +0300
Message-ID<u2fqqi$2bi76$1@dont-email.me>
In reply to#31865
On 28.4.2023 0.03, Ulf Samuelsson wrote:
> Den 2023-04-27 kl. 19:18, skrev Tauno Voipio:
>> On 27.4.2023 16.28, Andrew Smallshaw wrote:
>>> On 2023-04-27, pozz <pozzugno@gmail.com> wrote:
>>>> Il 27/04/2023 02:10, Rick C ha scritto:
>>>>
>>>>> I don't see where you have a choice, unless you want to add a 
>>>>> crystal to the ATtiny. Can the SAM chip send a clock?  You can use 
>>>>> an SPI port instead of a UART, or just send a clock to use for the 
>>>>> bit rate clock in the UART?
>>>>
>>>> No, this isn't an option.
>>>
>>> The other option would be to adopt a Manchester-encoded (self
>>> clocking) signal.  Wouldn't be true RS485 but would pass through
>>> transceivers and cabling at sensible baud rates.  Manchester coding
>>> is fine provided the clocks are within 2:1 of each other.  You will
>>> need to bit-bang the interface though, the UART won't handle it.
>>
>>
>> I doubt that the ATTiny can handle Manchester coding at the requested 
>> bit rate, and it may be difficult for the SAM.
> 
> Atmel implemented Manchester Coding in the SAM7 USART (My proposal)
> but the SAMD20 has a "SERCOM" module without Manchester Coding.
> I would look into the event system.
> 
> 
> The tiny will have to do it in S/W.
> /Ulf
> 
>>
>> In 2016, I made a processor unit using AT91SAM4E for IEC H1 Manchester
>> coded bus at 31.25 kbit/s. The trick was to innovatively use the timer
>> counter units of the chip. A timer used to measure the times between
>> pulse edges could be used to receive and decode the incoming data, and
>> a timer running at half of the bit rate (15.625 kbit/s) could be used
>> to send the data. The receiver needed to respond to interrupts at the
>> incoming edge rate, and the transmitter needed to respond at the
>> outgoing bit rate.
>>
> 
> The SAM4E USART supports Manchester Coding in H/W.
> The SAM4E UART does not.
> 
> /Ulf


The problem with the USART Manchester coder was in address markers
(intentional mis-codings). It was not possible to conform with the
markers in the IEC coding.

-- 

-TV

[toc] | [prev] | [next] | [standalone]


#31868

FromRick C <gnuarm.deletethisbit@gmail.com>
Date2023-04-27 17:45 -0700
Message-ID<18a1c260-3763-441c-bb3f-586ff27ce555n@googlegroups.com>
In reply to#31860
On Thursday, April 27, 2023 at 1:19:01 PM UTC-4, Tauno Voipio wrote:
> On 27.4.2023 16.28, Andrew Smallshaw wrote: 
> > On 2023-04-27, pozz <pozz...@gmail.com> wrote: 
> >> Il 27/04/2023 02:10, Rick C ha scritto: 
> >> 
> >>> I don't see where you have a choice, unless you want to add a crystal to the ATtiny. Can the SAM chip send a clock? You can use an SPI port instead of a UART, or just send a clock to use for the bit rate clock in the UART? 
> >> 
> >> No, this isn't an option. 
> > 
> > The other option would be to adopt a Manchester-encoded (self 
> > clocking) signal. Wouldn't be true RS485 but would pass through 
> > transceivers and cabling at sensible baud rates. Manchester coding 
> > is fine provided the clocks are within 2:1 of each other. You will 
> > need to bit-bang the interface though, the UART won't handle it.
> I doubt that the ATTiny can handle Manchester coding at the requested 
> bit rate, and it may be difficult for the SAM. 
> 
> In 2016, I made a processor unit using AT91SAM4E for IEC H1 Manchester 
> coded bus at 31.25 kbit/s. The trick was to innovatively use the timer 
> counter units of the chip. A timer used to measure the times between 
> pulse edges could be used to receive and decode the incoming data, and 
> a timer running at half of the bit rate (15.625 kbit/s) could be used 
> to send the data. The receiver needed to respond to interrupts at the 
> incoming edge rate, and the transmitter needed to respond at the 
> outgoing bit rate. 

That's if the entire job is handled in software, perhaps.  The USART can be used to send the bits as characters at the transmitter.  A USART can be used to handle the reception with software seeking edges.  I don't think that would be a huge burden at 38.4 kbps.  But then, I'm more used to FPGA work. 

-- 

  Rick C.

  ++ Get 1,000 miles of free Supercharging
  ++ Tesla referral code - https://ts.la/richard11209

[toc] | [prev] | [next] | [standalone]


#31870

FromTauno Voipio <tauno.voipio@notused.fi.invalid>
Date2023-04-28 10:00 +0300
Message-ID<u2fqun$2bi76$2@dont-email.me>
In reply to#31868
On 28.4.2023 3.45, Rick C wrote:
> On Thursday, April 27, 2023 at 1:19:01 PM UTC-4, Tauno Voipio wrote:
>> On 27.4.2023 16.28, Andrew Smallshaw wrote:
>>> On 2023-04-27, pozz <pozz...@gmail.com> wrote:
>>>> Il 27/04/2023 02:10, Rick C ha scritto:
>>>>
>>>>> I don't see where you have a choice, unless you want to add a crystal to the ATtiny. Can the SAM chip send a clock? You can use an SPI port instead of a UART, or just send a clock to use for the bit rate clock in the UART?
>>>>
>>>> No, this isn't an option.
>>>
>>> The other option would be to adopt a Manchester-encoded (self
>>> clocking) signal. Wouldn't be true RS485 but would pass through
>>> transceivers and cabling at sensible baud rates. Manchester coding
>>> is fine provided the clocks are within 2:1 of each other. You will
>>> need to bit-bang the interface though, the UART won't handle it.
>> I doubt that the ATTiny can handle Manchester coding at the requested
>> bit rate, and it may be difficult for the SAM.
>>
>> In 2016, I made a processor unit using AT91SAM4E for IEC H1 Manchester
>> coded bus at 31.25 kbit/s. The trick was to innovatively use the timer
>> counter units of the chip. A timer used to measure the times between
>> pulse edges could be used to receive and decode the incoming data, and
>> a timer running at half of the bit rate (15.625 kbit/s) could be used
>> to send the data. The receiver needed to respond to interrupts at the
>> incoming edge rate, and the transmitter needed to respond at the
>> outgoing bit rate.
> 
> That's if the entire job is handled in software, perhaps.  The USART can be used to send the bits as characters at the transmitter.  A USART can be used to handle the reception with software seeking edges.  I don't think that would be a huge burden at 38.4 kbps.  But then, I'm more used to FPGA work.


Had to bit-bang. The USART cannot create or detect IEC H1 standard
address marker octets.

-- 

-TV

[toc] | [prev] | [next] | [standalone]


Page 1 of 4  [1] 2 3 4  Next page →

Back to top | Article view | comp.arch.embedded


csiph-web