#avr Logs

Aug 11 2019

#avr Calendar

02:31 AM rue_mohr: Smidge204, sorry, I been occupied
02:36 AM rue_mohr: Smidge204, i2c master of slave
05:28 AM Smidge204: rue_mohr: Sorry I've been asleep. Master
07:13 AM Smidge204: Even after copying the code generated by Atmel START (converting it from C to assembly) I can't get it to work.
07:16 AM djph: Smidge204: whats going wrong?
07:18 AM Smidge204: Not entirely sure. I config the TWI registers, enable it, set an address , wait for the busy flag to clear just in case, then set a data byte. Nothing comes out
07:25 AM djph: line's physically set up right?
07:25 AM Smidge204: ...okay now I'm getting this weird triggering on my scope even though the uC isn't powered
07:26 AM Smidge204: Yeah 4.7K external pullup but it seems the uC is actually drawing power through it somehow
07:29 AM djph: wha...?
07:30 AM Smidge204: I dunno, with only the pullups and uC gound connected, I was getting state transitions on the uC pins. Connect Vcc and it stopped
07:34 AM djph: weird
07:42 AM Smidge204: Yeah this is a new behavior and super annoying since it interferes with my debugging efforts
07:43 AM Smidge204: https://i.imgur.com/tLZg4aT.png Triggering on Ch2 rising (blue) Ch1 (yellow) is, or shold be, SDA which has a 4.7K pullup on it. Vcc for the chip is floating.
07:44 AM Smidge204: All other pins are also floating except for reset, which is connected to the programmer
07:45 AM Smidge204: This just started happening this morning so I must've gotten it into a strange state
07:49 AM Smidge204: Or maybe I killed it? With both Vcc and Gnd of th epin disconnected, I'm getting +5v on all the other pins... including Vcc and Gnd
07:51 AM Smidge204: No still works it's just trying to power itself from the pullups
07:51 AM Smidge204: wtf
08:32 AM polprog: Smidge204: try pulling down reset with a 10k
09:09 AM Smidge204: Still happens
09:10 AM Smidge204: Heh if I pulse reset high it actually runs with Vcc floating
12:35 PM rue_mohr: Smidge204, you cant get i2c working?
12:36 PM rue_mohr: part of the answer is to save trouble and NOT use the hardware i2c
12:36 PM Smidge204: Yeah I'm rapidly approaching that point
12:36 PM rue_mohr: it takes less code and can be faster to use flurrys library
12:36 PM rue_mohr: which is REALLY good
12:36 PM rue_mohr: you trying to do master or slave?
12:37 PM Smidge204: Master
12:37 PM rue_mohr: the i2c hardware sucks
12:37 PM rue_mohr: on the tinys you have to manually pulse the clock line via a register
12:37 PM rue_mohr: yea, use flurrys i2c library
12:37 PM rue_mohr: its assembler with a C wrapper available
12:37 PM rue_mohr: I'v used it lots of times
12:38 PM Smidge204: I've written bitbang routines before but I'm trying to learn things :p
12:38 PM rue_mohr: I ported it to C and used it on a stm32
12:38 PM Smidge204: If the I2C hardware is really that bad then it's gonna be more trouble than it's worth
12:38 PM rue_mohr: USE FLURRYS LIBRARY
12:38 PM Smidge204: Okay okay :p
12:38 PM rue_mohr: atleast read his code
01:21 PM polprog: fleurys* :p
01:28 PM rue_mohr: thanks
01:28 PM Smidge204: It was good enough to find it :p
01:32 PM rue_mohr: see how he implements 9 bits using the flag?
02:09 PM Smidge204: Not yet, this code may need some massaging since the newer attiny isn't completely compatible
02:10 PM Smidge204: Different register names and shit, in particular
02:10 PM rue_mohr: er
02:11 PM rue_mohr: what code are you looking at
02:11 PM Smidge204: i2cmaster.S right now
02:11 PM rue_mohr: cause the flurry library for i2c master I was talking about is 100% software
02:11 PM rue_mohr: all it writes to is the direction, read, and write registers..
02:11 PM rue_mohr: ?
02:12 PM rue_mohr: ???
02:14 PM rue_mohr: do you mean like sbic SDA_IN,SDA ?
02:14 PM rue_mohr: cause he's using a macro to define things like SDA_IN and SDA
02:15 PM rue_mohr: SDA_IN will be defined, for example to PINA
02:15 PM rue_mohr: where SDA would be defined to, for example, 7
02:15 PM rue_mohr: inwhich case PINA,7 is your SDA line
02:15 PM rue_mohr: ???
02:16 PM Smidge204: I'm only just getting around to picking it apart. Immediately I noticed that SCL_DDR needs to be defined as VPORTA_DIR at the very least
02:17 PM rue_mohr: you ahve to define a bunch of things
02:17 PM rue_mohr: the ports and pins your using
02:19 PM rue_mohr: pin for data, pin for clock, port for data line, port for clock line, ports for direction of data line
02:19 PM rue_mohr: I'm pretty sure tho, that you will find that compiled anyhow, flurrys bit-bang code is smaller than the atmel library for using the hardware
02:25 PM Smidge204: References io.h which does not have the appropriate definitions for the attiny814 :D
02:33 PM nohit: fleurys*
02:37 PM rue_mohr: there is one, its the file that defines thigns like PINA
02:38 PM rue_mohr: and PORTA
02:43 PM Smidge204: You can't access the port registers bitwise. You have to use the virtual ports. The only other way is to write the entire port register using the STS k,Rr instruction
02:56 PM LeoNerd: Smidge204: For working on the new ATtiny chips you might need to apply some fixes to your avr-libc to get the right definitions
02:57 PM LeoNerd: http://leonerds-code.blogspot.com/2019/06/building-for-new-attiny-1-series-chips.html -- explains what works for me
07:51 PM rue_mohr: what
07:52 PM rue_mohr: avr has always had bitwise instructions
07:52 PM rue_mohr: is it one of the new ones since microchip bought them?
07:52 PM rue_mohr: microchip is well on their way to screwing up avr
11:44 PM day__ is now known as day