#avr Logs

Jul 31 2022

#avr Calendar

03:20 AM specing_ is now known as specing
02:31 PM kodcode: Hi all. Maybe I can break the silence here with a beginners question. What's the difference between pin/port/registor?
02:33 PM kodcode: I've done some reading on it, but did not get it clear. Do several pins belong to one port?!
02:33 PM qu1j0t3: kodcode: Yes.
02:34 PM qu1j0t3: kodcode: port and register are often used interchangeably almost. a group of registers control a port (e.g. direction reg + input reg + output reg)
02:34 PM qu1j0t3: kodcode: a "pin" literally speaking is one ofthe gpio lines (input or output)
02:34 PM qu1j0t3: kodcode: an avr port groups 8, yes.
02:35 PM kodcode: OK. So if I define a port with DDRx to be input or output, all those pins are or input or output?
02:35 PM qu1j0t3: no
02:35 PM qu1j0t3: you define the direction per bit in the register.
02:35 PM qu1j0t3: bit = one pin, in any register
02:35 PM qu1j0t3: unless i misread you.
02:36 PM kodcode: I am still not clear, Sorry. Do you refer to the pins actually sticking out from the AVR as pins?
02:36 PM qu1j0t3: you define diretion for 8-at-a-time according to the value you put in the register.
02:36 PM qu1j0t3: kodcode: if it's DIP, then exactly yes. or the SMT pad :)
02:36 PM kodcode: DIP, SMT. Help.
02:36 PM kodcode: Sorry, just find it hard where to start here
02:36 PM qu1j0t3: DIP = dual inline package, through hole tech. but many boards use SMT.
02:36 PM qu1j0t3: surface mount.
02:37 PM qu1j0t3: DIP is what we associate with older IC "pins" yes.
02:37 PM qu1j0t3: my Duemilanove uses a DIP MCU chip. Pins into a socket.
02:37 PM qu1j0t3: maybe yours does too.
02:37 PM kodcode: OK. So, maybe let me ask like this. How can I define if one (I don't know yet which one is the right for that) would be 5V input or output
02:37 PM qu1j0t3: but in the end, the package doesn't mater. it's one electrical pin or pad = 1 GPIO, yes.
02:38 PM qu1j0t3: kodcode: By setting its bit in the direction register.
02:38 PM kodcode: So, what is the purpose of DDRx then?
02:38 PM qu1j0t3: a direction register controls 8 "pins"
02:38 PM kodcode: Oh, OK
02:38 PM kodcode: So, every 8 pins have to be or in our out?
02:38 PM qu1j0t3: no.
02:38 PM kodcode: Grr
02:39 PM qu1j0t3: qu1j0t3 | you define the direction per bit in the register.
02:39 PM qu1j0t3: qu1j0t3 | bit = one pin, in any register
02:39 PM qu1j0t3: the value you put in the direction register has 1's for output pins and 0's for input pins.
02:39 PM qu1j0t3: you set 8 at a time because the register is 8 bits.
02:39 PM kodcode: Oh, OK
02:40 PM kodcode: So, now what you call pin is not one of the 28 pins of my atmega328p, right
02:40 PM qu1j0t3: in C you can pretend you're setting just one, with operators like |= and &= , but i don't know if you're writing C
02:40 PM qu1j0t3: kodcode: Right, not all the pins are GPIO.
02:41 PM qu1j0t3: but a GPIO line is a single physical pin on the MCU.
02:41 PM kodcode: qu1j0t3, well, what happened is that I started with some simple Arduino things in Arduino IDE but I really want to know what the IDE actually does, so I decided to go down a few levels
02:42 PM qu1j0t3: whether input or output.
02:42 PM kodcode: OK, I am getting it clearer now
02:42 PM qu1j0t3: kodcode | So, now what you call pin is not one of the 28 pins of my atmega328p, right // Sorry I wasn't clear enough. the answer to this is YES.
02:42 PM qu1j0t3: a GPIO is one of the _physical_ pins.
02:43 PM qu1j0t3: but a PORT groups eight of them.
02:43 PM qu1j0t3: (regardless of layout on the IC itself)
02:43 PM kodcode: PORT groups eight physical pins?
02:43 PM qu1j0t3: yes a port groups 8. and a port is controlled by several 8 bit registers.
02:43 PM qu1j0t3: but a PIN is just one physical pin, or bit in a register.
02:43 PM kodcode: So, I have 24 pins and 4 don't know what they are then
02:44 PM qu1j0t3: you need the datasheet.
02:44 PM qu1j0t3: or schematic of your arduino
02:44 PM kodcode: This 300 pages monster
02:44 PM qu1j0t3: that tells you exactly what each one is
02:44 PM qu1j0t3: you only need 1 page, the pinout page.
02:44 PM qu1j0t3: the schematics are also pretty easy to read
02:44 PM kodcode: OK, I found it before but did not know what to look for there, so now I'll have a look again
02:45 PM qu1j0t3: make sure you get the right package. DIP is the terminology for the through hole package that you are probably using.
02:45 PM qu1j0t3: (same as me)
02:45 PM kodcode: Fascinating field... Thanks for all the support, qu1j0t3
02:45 PM qu1j0t3: yw any time
02:46 PM kodcode: I am like picking up things here and there and try to fill up the missing holes
02:56 PM kodcode: How come there are ports B, C, D? Why dont' start with A?!
03:03 PM nuxil_ is now known as nuxil
03:06 PM nuxil: on some chips they do start at A. example the one im messing with now. mega 2560 got port a,b,c,d,e,f,g,h,j,k
03:06 PM nuxil: they skipped i on this chip :p
03:08 PM kodcode: nuxil, OK. So this isn't a rule then. Thanks
03:10 PM nuxil: i dont know is there is any rules for the naming convension for the ports.
03:11 PM nuxil: if you look at example tinys. they have port b, instead of port a.
03:16 PM nuxil: im sure there is a reason they skip sertan letters. for a perhaps its to not confuse buslines related to adresses or analoge. who knows.
03:18 PM kodcode: nuxil, alright. Thanks.
03:22 PM kodcode: Is there any AVR chip that supports Wifi with a cam? I have an ESP32-cam here and have a hard time getting it programmed in my enviroment.
03:23 PM nuxil: ouch. you probably need to look at one of the 32bit ones arm or whatever.
03:24 PM nuxil: megas are too slow for that
03:27 PM exp: darn no matter what i do, my xmega will not CRC its flash consistently with any other crc algorithm
03:28 PM exp: has anyone had experience with doing this? i've generated a simple test file, flashed it and it appears correctly in the debugger, i generated crc locally and i'm trying to compare it against the crc generator onboard
03:28 PM exp: local generator has same polynomial, matches an online crc32 generator too
03:30 PM nuxil: kodcode, if you need wifi+camera. just get a PI :p
03:31 PM nuxil: exp crc16 or 32?
03:31 PM exp: nuxil: 32, think it's mandatory when doing flash
03:32 PM exp: i've covered i think every case i can think of, the addr and data registers seem to be set correctly, i've read the examples in ASF and my code is practically identical
03:33 PM exp: i'm using the CRC in 16 elsewhere but not checking it against external sources at teh moment
03:39 PM nuxil: maybe the onboard gen is using a different crc32, as in different polynomal. threr are different types. CRC-32, CRC-32C, CRC-32K, CRC-32K2, CRC-32Q
03:41 PM nuxil: but i woudnt know. havent messed with this kind of stuff.
03:46 PM exp: yeah i used an online calculator to check my crc32 against all the algorithms
03:47 PM exp: what i'm generating matches CRC-32, what the xmega is generating does not seem to match anything lol
03:56 PM nuxil: hmn. can you reverse it perhaps. you have the file. and the value it generates. so perhaps there is a way to reverse it to see what it uses.
04:00 PM nuxil: dont know how good that is or if it works :p https://md5hashing.net/hash/crc32
04:01 PM nuxil: also found this. not sure if its relevant to you https://savannah.nongnu.org/bugs/?37901 .it a bit old
04:02 PM nuxil: https://www.avrfreaks.net/comment/1761836#comment-1761836
04:04 PM nuxil: anyway. time to go and be a bit medieval on the marlinfw source and remove some crap out.
04:05 PM exp: thanks nuxil i have played about with the crc values in this generator
04:06 PM exp: and found that if i set the init value to 0, what i get out matches the values in CHECKSUM.. without the inverting + bit flipping
04:06 PM exp: as it seems that is built in
04:22 PM exp: yes and flipping about a bit, it looks like i can just match directly without having to bit reverse and invert, that makes life easy