#avr Logs

Aug 13 2019

#avr Calendar

06:24 AM day: why would you NOT use hw i2c? o.o
06:29 AM day: shit not scrolled down D:
07:11 AM Fuchikoma: Classic IRC error
07:14 AM Fuchikoma: As a follow-up, I did manage to get a bitbang I2C routine working. It's maybe 30-40 instructions long and honestly I don't see a hardware implementation being much smaller
07:29 AM LeoNerd: Cute
07:29 AM LeoNerd: Though usually I go for hardware I²C less for code size, and more because it can be done sortof-async via interrupts, so you can fire it and let it run in the background until it's done
07:30 AM LeoNerd: Can be especially handy for those slower 100kHz buses
07:31 AM LeoNerd: 100kHz vs 20MHz CPU clock, that's 200 instructions per bit. 1800 instructions per 9bit word cycle
07:44 AM Fuchikoma: That's a very fair point
07:45 AM Fuchikoma: Also handy if you're acting as a slave device, so you can get the interrupt on address and not worry about constnatly listening
07:46 AM davor_ is now known as davor
08:34 AM djph: ^ all that -- hardware is less about "number of lines of code" and more about "waste fewer CPU cycles"
08:37 AM AppXprt: do you need an ADC for bit banging?
08:39 AM djph: AppXprt: not usually
08:39 AM AppXprt: should an atmega32u2 be able to get the job done? I have datasheet link if needed..
08:39 AM AppXprt: minimus avr
08:40 AM AppXprt: http://ww1.microchip.com/downloads/en/DeviceDoc/doc7799.pdf
08:40 AM djph: it's usually just two pins ("data" and "clock") -- for bit in byte; if bit==1 then data high; else data low;end if; clock high; clock low; loop;
08:41 AM djph: AppXprt: what about it?
08:41 AM AppXprt: ahh okay so you have to connect to each pin individually to map out an entire port?
08:42 AM djph: of course
08:42 AM djph: wait, what?
08:43 AM AppXprt: bitbanging can map out jtag/spi/i2c interfaces automatically right?
08:43 AM djph: for bitbanging you can use whatever pins you want (e.g. PB0, PB1 for all it cares)
08:43 AM djph: not at all
08:43 AM djph: "bit banging" is just "I'm gonna tell the CPU to toggle these pins so I can pretend I have this module"
08:44 AM djph: ... or, as in my case "because I still don't know how to slow this down enough to make the slave chip listen"
08:46 AM AppXprt: yea but could you not say for instance have a piece of hardware that can detect protocol and set JTAG pins configuration based on what it determines?
08:47 AM AppXprt: automatically detect the pinou
08:47 AM AppXprt: pinout
08:50 AM AppXprt: bus pirate does this?
08:51 AM twnqx: not that i am aware of
08:51 AM twnqx: glasgow might
09:00 AM Fuchikoma: "bit banging" just means you are manually toggling pin states to transmit the data
09:00 AM Fuchikoma: Instead of letting purpose built silicon handle it for you
09:01 AM Fuchikoma: As for detecting protocol... that would be extremely tricky. You'd have to at least know how to recognize a correct signal first
09:04 AM twnqx: even worse with a protocol with no fixed voltage like jtag :P
09:13 AM polprog: why :D? if you only expect to have two logic levels, one of them zero volts, then its pretty simple
09:13 AM twnqx: but the other can be anything from 0.8V to 5V
09:14 AM polprog: so just trigger at .5
09:18 AM polprog: sweet
09:18 AM polprog: cleaned up bedroom floor
09:18 AM polprog: and a cupboard i never opened in the past 8 years
09:18 AM polprog: found 3 stepper motors
10:14 AM AppXprt: so can jtag boundary scan do pinout autodetection?
10:28 AM twnqx: no
10:29 AM twnqx: or do you mean a particular product?
10:30 AM Fuchikoma: Still not clear what you mean by "pinout autodetection"
10:31 AM Fuchikoma: What are you trying to detect the pinout of?
02:44 PM AppXprt: can someone help me find a cheap debug probe for detecting embedded debug port type and pinouts or a development board that could do it?
02:45 PM cehteh: no docs?
02:54 PM Fuchikoma: AppXprt you are seriously up shit's creek with that. Best you can do is identify the chip in question, find the datasheet and work from there
02:55 PM Fuchikoma: Especially in the microcontroller world, any pin can have any function and even multiple functions at the same time.
03:16 PM eadthem_work: I am having a bit of issues with some inline ASM in c/c++ for a AVR Mega2560 (On arduino but not the point).
03:16 PM Kliment: What issues?
03:17 PM eadthem_work: on this page https://ucexperiment.wordpress.com/2013/06/03/gcc-inline-assembler-cookbook/ the examples for SBI and CBI constantly give "error: impossible constraint in 'asm'"
03:17 PM eadthem_work: but if i put in as "cbi PORTH %0" it works
03:18 PM eadthem_work: its like the constraint of I is no longer valid in my version of avr-gcc for a port address for CBI and SBI
03:18 PM eadthem_work: it is specificly the port portion that causes issues.
03:19 PM Kliment: oh eh, I never used the contraints functionality
03:19 PM eadthem_work: btw im on avr-gcc 5.4.0 atmel 3.6.1
03:19 PM Kliment: constraints*
03:19 PM eadthem_work: ya i use to just do ASM for AVR directly after that C/C++ was sufficant for everything
03:20 PM eadthem_work: for this i need speed in this block of code. as indicated by testing.
03:20 PM Kliment: I don't understand how the constraint is useful here
03:21 PM eadthem_work: let me remake a smaller example
03:24 PM eadthem_work: https://paste.opensuse.org/716ae8c2
03:24 PM eadthem_work: so i have it exactly pinpointed but im not sure why its causing issues.
03:26 PM eadthem_work: I can make this work as it sits with the hard coded in each location PORTH
03:26 PM eadthem_work: just not ideal would rater have 1 define set it
03:28 PM Kliment: does the macro work outside the asm context?
03:28 PM eadthem_work: what PORTH seams to
03:28 PM eadthem_work: not sure i have it used anywhere like that
03:29 PM eadthem_work: i can try that in a bit
03:31 PM Kliment: I mean _SFR_IO_ADDR(PORTH)
03:31 PM Kliment: Does it return a sensible value?
03:33 PM eadthem_work: ya aparently yes, because what i have setup now is #define __DRIVER_AVR_PORT_NAME__ PORTH
03:34 PM eadthem_work: and im using __DRIVER... in each location
03:35 PM Kliment: Okay, and it you put the value it returns in there explicitly does that work?
03:36 PM eadthem_work: eh well it compiled, let me sort out the ELF error
03:38 PM Kliment: macro handling has limitations in asm context
03:38 PM eadthem_work: im not able to tell if PORTH is sensable. it seams to be a macro to 0x102
03:38 PM eadthem_work: eclipse understands it, i do not have the code anywhere where i can use it like that though
03:39 PM eadthem_work: i am looking it up in the datasheet what it shuld be for PORTH
03:41 PM eadthem_work: the datasheet says PORTH is register address 0x102 so thats the right address
03:55 PM eadthem_work: Its PORTH PORTB works fine
03:55 PM eadthem_work: anything with PORTH
03:56 PM eadthem_work: aparently its to high up for CBI and SBI to work with it
03:56 PM eadthem_work: maybe CBIW
03:57 PM eadthem_work: nvm on that
11:41 PM day__ is now known as day