#avr Logs

Mar 17 2019

#avr Calendar

12:54 AM day_ is now known as day
07:50 AM HelloShitty: Hello peeps
07:50 AM HelloShitty: I'm trying to write my own code to use TWI interface on Mega4808 to read a temperature sensor value
07:51 AM HelloShitty: but I'm clueless about the settings the user manual of Mega4808
07:51 AM HelloShitty: They say I need to set SDASETUP and SDAHOLD prior to initialise the interface
07:52 AM HelloShitty: I'm using an MCP9808 temp sensor
07:52 AM HelloShitty: and I have 4 options for SDAHOLD for Mega4808
07:52 AM HelloShitty: 0x0 is OFF
07:52 AM HelloShitty: 0x1 is 50ns nominal value (range from 36 up to 131ns)
07:53 AM HelloShitty: 0x2 is 300ns nominal (range from 180 up to 630ns)
07:53 AM HelloShitty: 0x3 is 500ns nominal (range from 300 up to 1050ns)
07:54 AM HelloShitty: In MCP9808 datasheet I can se, for example:
07:54 AM HelloShitty: Start Condition Setup time - 600ns
07:54 AM HelloShitty: Start Condition Hold Time - 600ns
07:55 AM HelloShitty: Stop Condition Setup Time - 600ns
07:55 AM HelloShitty: Data in Setup time - 100ns
07:55 AM HelloShitty: Data in Hold time - 0ns
07:55 AM * cehteh thinks you dont need to repeat the datasheet here
07:55 AM HelloShitty: Data out Hold Time - 200ns
07:56 AM HelloShitty: I'm not sure what to choose here
07:56 AM HelloShitty: Any help?
07:57 AM cehteh: https://en.wikipedia.org/wiki/I2C
07:58 AM cehteh: check the temperature sensor's datasheet for its timing constraints/speed settings
07:59 AM HelloShitty: I did
07:59 AM HelloShitty: That's what I was typing above
08:00 AM HelloShitty: those 600ns are related to MCP9808 timings
08:00 AM HelloShitty: I'm just not sure which option to set from those 4 options
08:01 AM HelloShitty: Or better, I'm not sure if I should choose the 300ns or the 500ns timing option
08:02 AM cehteh: i dont know these chips but to me it looks that the 500ns looks better in the right range
08:02 AM cehteh: what does 'nominal' mean there? is there some register/prescaler which changes the timing. look into that
08:07 AM HelloShitty: I'm not sure about any prescaler setting
08:08 AM HelloShitty: I haven't read about it yet in TWI section of User Manual
08:08 AM cehteh: maybe you should :D
08:17 AM LeoNerd: Pick the fastest time that is slow enough for all the slave chips
12:37 PM rue_bed2: flurrys i2c master library is pretty damn good
12:41 PM rue_bed2: HelloShitty, did you come up with another solution yet?
02:39 PM [1]MrMobius is now known as MrMobius
04:29 PM HelloShitty: rue_bed2: I was away from the project almost all day, so no, not yet!
04:35 PM rue_mohr: HelloShitty, why dont you use flurrys i2c libary?
04:35 PM rue_mohr: give it a try anyhow
04:36 PM HelloShitty: I have no idea if it suits Mega4808
04:37 PM HelloShitty: Registers in this chip were written in a very different way (I guess) in header files...
04:43 PM HelloShitty: For instance, peter's libraries use this register macro TWSR that cannot be found in Mega4808 header file!
04:44 PM HelloShitty: Microchip guys came up with a way of using these names that is way different and peculiar and thus I think I can't use that libraries
05:16 PM LeoNerd: The ATmega4808 is a new, quite different kind of chip, to the older ATmegas
05:16 PM LeoNerd: The new mega 0-series
09:08 PM rue_mohr: the new avrs are not avrs their ****PICs
09:09 PM rue_mohr: but you can adjust flurrys library, its easy to adjust bit-banged libraries
09:10 PM rue_mohr: flurrys libraries shouldn't be using any of the two wire registers,
09:10 PM rue_mohr: its a bit-banged library...
09:10 PM rue_mohr: which is why it always works
09:11 PM rue_mohr: and the way most of those subsystems works, it usually takes up less software space and runs faster or as fast as the hardware system
09:13 PM rue_mohr: HelloShitty, if you cant get flurrys library working, I have a C port of it, its not as fast tho