F_CPU_CORRECTED ??

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Can someone tell me what this value is, in the context of Arduino with ATmega4809 TWI? Or, how does it relate to F_CPU?

 

Many thanks

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The 4809 Arduinos run off of the internal clocks.  Those are reasonably accurate, and have calibration and tempco values that are loaded that are supposed to make them more accurate (and/or adjustable), but there are also some signature row values indicating the actual measured error AFTER calibration for the really picky folk.

See section 9.3.4.1.1 of the (rev C) datasheet.

 

(I think for Arduino purposes, it's a lot of overkill, and it wrecks some of the various "efficiency" efforts that count on F_CPU being constant.  https://github.com/arduino/ArduinoCore-megaavr/commit/d94a1955551e49ba232d60bf9950fd56853b59dc#commitcomment-34988579 )

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've never heard of F_CPU_CORRECTED - in what software context does this appear ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The Nano-EVERY runs on 16MHz.   You can produce a 20MHz variant if you want.

 

I don't see what relevance this has with TWI.

Standard I2C is 100kHz.   Which is not very onerous.

 

I2C slaves are specified for their maximum bus speed.   Legacy chips are mostly 100kHz e.g. DS1307

Many modern chips will do 400kHz.

 

There is no minimum speed for I2C bus.   Speed is seldom an issue for most sensors.

You only worry about speed if there is high traffic e.g. EEPROM, SRAM, OLED, COG, ... chips.

In which case you ensure that the bus runs at the max speed for the relevant Slave chip(s).

 

Note that I2C_START must never be faster than than the slowest device on the bus.

You can probably speed up after you have seized a fast Slave.    But you risk an un-addressed slow device misinterpreting fast bus traffic as a START.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Reference to this (assumed) define value appears in the Microchip written Arduino TWI module and it is used instead of F_CPU in the computation of the TWI baud rate.

 

It can be found here: https://github.com/arduino/Ardui... in the function void TWI_MasterSetBaud(uint32_t frequency).

 

It also blows my mind that this function forces the baud rate into specific values of 100KHz, 400KHz, etc. 

 

This and a number of other attributes, such as stacking of function calls into iSRs, makes me really doubt the code. Perhaps this module is an attempt to perpetuate "Arduino Bloat"?

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I guess I should have noticed this was the "Arduino" forum  so this "_CORRECTED" thing is an Arduino concept is it. Live and learn.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Don't know about this "_CORRECTED" thing. That is why  I asked.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net