#avr Logs

Nov 24 2017

#avr Calendar

03:12 AM absynth is now known as dan2wik
04:14 AM nohitzzz: polprog here's a VU meter for you https://www.waves.com/lpn/black-friday-2017/free-plugin
06:58 AM polprog: nohitzzz: looks cool ;)
12:02 PM _kl0wn is now known as kl0wn
12:06 PM fooman2011: Hello. I have successfully uploaded a sketch to my Attiny2313 using an Arduino as ISP. But I have a strange problem. The pin mapping seems to be incorrect. For instance, the pin 7 in the sketch is mapped to the physical pin 9 of my attiny2313. Could you please help me to solve this problem ?
12:07 PM polprog: fooman2011: are you using digitalWrite or PORT variables?
12:07 PM polprog: beacuse if you use arduino library on the tiny2313, you need to search for the pin mapping for 2313
12:08 PM fooman2011: currently I have "7" hard coded. I have tried PIND5 but it's not working
12:08 PM polprog: PIN registers dont work like that
12:08 PM polprog: ;)
12:08 PM polprog: read emil.fi/avr
12:14 PM fooman2011: polprog: I read it. But I'm under Windows, not Linux and I'm using the arduino IDE to compile and upload the program. And I don't see something about "pin remapping"
12:16 PM polprog: try a simple led blinker using PORT/PIN register as io
12:17 PM polprog: connect a led to some pin (say PD0) and the program would have just PORTD = 0x01; in main()
12:17 PM polprog: if it works the led should light up
12:18 PM Emil: fooman2011: if you read the guide
12:18 PM LeoNerd: Usually AVR pins are configured as inputs by default on boot, so you'll have to poke at DDRD also
12:18 PM Emil: fooman2011: you would notice that it works on arduino, too
12:18 PM Emil: I personally use the arduino ide to program
12:18 PM polprog: LeoNerd: good remark, i forgot ;)
12:18 PM Emil: LeoNerd: not just usually
12:18 PM Emil: LeoNerd: guaranteed iirc
12:19 PM LeoNerd: I was keeping my options open, in case there's some obscure chip with output-only pins on it
12:19 PM Emil: true, true
12:19 PM Emil: fooman2011: also, mate
12:19 PM polprog: you can always read my guide on assembly programming, it's OS-independent :P
12:19 PM Emil: PINxn is _not_ a thing
12:20 PM fooman2011: I'm planning to use some libraries like this one: https://github.com/adafruit/TinyWireM/blob/master/USI_TWI_Master.h
12:21 PM polprog: i wanted to try a USI library
12:21 PM fooman2011: I have to define the PORT values by myself ?
12:21 PM Emil: polprog: >usi lib
12:21 PM Emil: polprog: write your own :D
12:21 PM polprog: but i think they are worthless so i wrote my own
12:21 PM Emil: usi is just a serial output stream
12:21 PM polprog: Emil: are you in a hurry? ;)
12:22 PM Emil: oh :D
12:26 PM fooman2011: The lib is using "PINB5" as "SDA pin"
12:26 PM LeoNerd: fooman2011: <avr/io.h> will set them all up for you
12:27 PM fooman2011: LeoNerd: I have include arv/io.h and when I use PINB5 it not the correct pin
12:27 PM LeoNerd: ??
12:27 PM LeoNerd: PINB5 isn't a thing
12:28 PM LeoNerd: PINB is the input register for the B port
12:28 PM LeoNerd: It has bits, such as bit number 5
12:28 PM fooman2011: Oh ok. Is there a "define" for the pin number ?
12:29 PM LeoNerd: ??
12:29 PM LeoNerd: You're looking at this wrongly
12:29 PM LeoNerd: The idea that every pin is assigned a unique number in the program is a purely Arduino-shaped abstraction over the top of the actual hardware. That doesn't exist
12:29 PM fooman2011: #define SDA_PIN_NUMBER 14
12:29 PM LeoNerd: AVR IO pins are grouped up into ports
12:29 PM fooman2011: something like that
12:30 PM LeoNerd: Each PORT is backed by a few 8bit registers, that are read/written in a group
12:30 PM LeoNerd: For example pin PB5 is the 5th bit of the PORTB / PINB register set
12:31 PM fooman2011: so there is a define for PORTB and PINB but not for the pin PB5 ?
12:31 PM LeoNerd: Indeed so
12:31 PM LeoNerd: Well... there -is- a #define'ed constant PB5 but that is just the number 5
12:31 PM LeoNerd: It's there to try to make assignments like PORTB |= _BV(PB5); look a little more obvious
12:31 PM fooman2011: ok, I can define it by myself to 14.
12:32 PM LeoNerd: You can but the number 14 is entirely opaque to anything else
12:32 PM LeoNerd: Outside of Arduino, the number 14 is meaningless
12:32 PM LeoNerd: The PB5 pin is the 5th bit of the B port. That's it
12:32 PM LeoNerd: The idea that that corresponds to the number 14 is purely an invention on Arduino's part
12:34 PM fooman2011: Ok I think that I understand. The int value associated to pins and the functions like pinMode, digitalWrite. It's is for simplification.
12:34 PM LeoNerd: You might call it simplification
12:34 PM LeoNerd: In practice it turns out to massively complicate things
12:35 PM fooman2011: I should use code like PORTB blabla PB blabl output, then same kind of code to set HIGH level
12:35 PM LeoNerd: Indeed. E.g. the code I showed you above
12:36 PM fooman2011: this: PORTB |= _BV(PB5) is set the pin 5 of the port B to HIGH ?
12:37 PM LeoNerd: Indeed
12:37 PM fooman2011: ok
12:37 PM LeoNerd: By talking to the actual hardware, too. Rather than the many layers of Arduino mess
12:37 PM fooman2011: and the code to set a pin as "output"
12:38 PM LeoNerd: That'll need a similar bit-twiddling on the DDRB register; the "data direction register for port B"
12:38 PM fooman2011: This low level programming (I mean instead of using the pinMode or digitalWrite function) has a specific name ?
12:38 PM LeoNerd: I don't imagine it does, or needs one
12:39 PM LeoNerd: It's the way almost everyone does almost everything, or at least did before Ardunio came along
12:39 PM fooman2011: because on google if 'im looking for "how to set a pin as output" every result told me to use pinMode(pin, OUPUT)
12:40 PM LeoNerd: You probably typed "arduino" in
12:40 PM LeoNerd: Also be aware that google will massively bias results towards e.g. newbies complaining in newbie help forums, so you'll get that kind of answer
12:41 PM fooman2011: lol ok
12:42 PM fooman2011: just could you please tell me in DDR register, a bit 1 means input or output ?
12:42 PM LeoNerd: Offhand I forget. I'd be reading the datasheet at this point
12:42 PM fooman2011: I just make a blinking led and then i will read doc
12:42 PM LeoNerd: Surely a far better bet than random googling
12:43 PM fooman2011: unfortunately DDR is contained in "address" so a find in datasheet give me a lot of results :p I will find it.
12:43 PM fooman2011: Thanks very much for your help guys
12:44 PM Emil: fooman2011: https://emil.fi/avr goes over
12:44 PM Emil: whast DDR and PORT mean
12:44 PM Emil: and how to use them
12:44 PM LeoNerd: Read its main description in the "IO ports" section of the sheet
12:44 PM LeoNerd: Hrm.. I wonder why people still call these things "datasheets" - it's been a long time since more-or-less any component was simple enough to have a single page sheet of data about it
12:45 PM LeoNerd: Some of the STM32 docs go to more than a thousand pages
12:46 PM Emil: heh
12:46 PM Emil: It's the same thing as referring to a scientific text as a paper
12:46 PM nohitzzz: they used to be data books
12:46 PM nohitzzz: before internet
12:47 PM Emil: Interesting
12:47 PM LeoNerd: Hrm? I'm thinking waaaay older than that
12:47 PM LeoNerd: Right back at 1920s, 30s... If you buy a valve tube, it came with a one-page sheet of paper with its important characteristics
12:47 PM LeoNerd: That was the "data sheet"
12:48 PM LeoNerd: Moving on to 60s, 70s transistors,.. even then you can probably get all the relevant stuff on one page
01:40 PM polprog: demo trivia:
01:40 PM polprog: compare this: https://www.youtube.com/watch?v=lVdWxKZVYC0
01:40 PM polprog: with this: https://www.youtube.com/watch?v=Wi6ZG2CmHo8
01:40 PM polprog: music is from '99, demo from 2014 ;)
01:43 PM polprog: actually this was the original, zonk: https://www.youtube.com/watch?v=IZAn8pTR2F0
05:09 PM enh: rue_bed: ?
05:10 PM enh: Where is Lambda_Aurigae? Aybody heard of him?
05:17 PM Tom_L: i am not his keeper
05:18 PM enh: True.
05:18 PM enh: But you could have heard of him.
05:18 PM Tom_L: i have heard _of_ him
05:18 PM enh: Is he ok?
05:18 PM Tom_L: it's a holiday
05:19 PM enh: He has been off for two weeks.
05:19 PM enh: I thought his health got worse
05:20 PM Tom_L: i was off for one and you didn't miss me :(
05:20 PM enh: You are jealous
05:20 PM enh: https://www.youtube.com/watch?v=ofBKDl7TMTE
05:21 PM enh: I'd like cehteh to see this video, but he seems to be away
05:22 PM enh: We should have each other's email. In case a meteor strikes the planet and hits the freenode servers.
05:22 PM enh: :)
05:23 PM Tom_L: the ones that care know how to find me
05:23 PM polprog: private teamspeak over vpn
05:24 PM enh: I do not know how to find you, Tom.
05:24 PM enh: or you, polprog
05:24 PM enh: enhering@gmail.com my email.
05:24 PM Tom_L: rue does
05:25 PM Tom_L: you want spam i guess
05:26 PM enh: I have a good filter.
11:38 PM day__ is now known as daey