#avr Logs

Oct 18 2018

#avr Calendar

01:03 AM rue_mohr: --
04:04 AM kakimir: yes hello
04:04 AM kakimir: question
04:05 AM kakimir: do all attinys turn on pull-up to pin when pin is configured as input and PORTx bit for the pin is written 1?
04:06 AM kakimir: as there is another register called PUEx
04:10 AM kakimir: hmmm!!
04:10 AM kakimir: "Unlike the older AVR chips, such as the ATmega328 and ATtiny85, the ATtiny10 enables pullup resistors using a separate pullup register, PUEB"
04:11 AM kakimir: I'd better check one code that is already in production.. I think it didn't have any need for pullups afaik.
04:14 AM kakimir: true
06:59 AM kakimir: is atomic read of 16 bit timer value to uint16_t really ok?
06:59 AM kakimir: I mean it has to be done in order low byte high byte
07:39 AM LeoNerd: Technically, only while timer is stopped
07:44 AM kakimir: there is C example in datasheet that does atomic read
07:44 AM kakimir: i = TCNT1;
07:44 AM kakimir: so it's not guaranteed to work right?
07:47 AM skz81: it is because of : << When the low byte of a 16-bit register is read by
07:47 AM skz81: the CPU, the high byte of the 16-bit register is copied into the TEMP register in the same clock cycle as
07:47 AM skz81: the low byte is read, and must be read subsequently. >>
07:48 AM skz81: The read itself from CPU point of view is not atomic but this TEMP thing allows to take a "snapshot" of all 16 bits at once.
07:56 AM kakimir: activating shadow register requires low byte to be read first
07:56 AM kakimir: that is my concern in C implementation of the read
07:59 AM skz81: ermmm... The DS says "in the same clock cycle as". That's hardware featured...
08:26 AM polprog: as far as i know, most modern gcc versions detect those reads and emit the right code
08:26 AM polprog: or are we talking about assembly here?
08:27 AM polprog: either way the examples in datasheet are valid
08:44 AM kakimir: avr-gcc does the job?
08:44 AM skz81: I mean, the fact of reading the low byte triggers the fact that TEMP is loaded with ythe high byte of the counter. At same clock cycle. So to answer the original question (about atomicity of the read) : yes it is OK.
08:44 AM kakimir: good to know
08:47 AM skz81: Not avr-gcc here, actually, but AVR hardware. gcc detects it's a 16 bit value and generates the right ASM/binary code (2 byte readings)
08:48 AM skz81: Well, TCNT1 definition is provided by avr-gcc specific headers...
08:48 AM kakimir: nice
08:48 AM kakimir: #define TCNT1 _SFR_IO16(0x20)
08:49 AM skz81: Yup.
08:50 AM kakimir: doesn't say much but I'll trust it will do it
08:50 AM rue_mohr: your worried about an interrupt when your modifying a 16 bit register?
08:50 AM kakimir: atomic
08:50 AM kakimir: done
08:51 AM rue_mohr: you can do 32 bit operations if you want, not sure how they would collide with interrupts, but they will work
08:51 AM skz81: What I meant, is that without the TEMP thing mecanism, the read wouldn't be "atomic" anymore. If when you read low it was 0xFF, on next cycle when you read the high part, low may have overflown...
08:51 AM rue_mohr: I dont think 64 bits worked
08:51 AM rue_mohr: the hardware freezes the other half till the read is done
08:52 AM rue_mohr: says so in the documentation
08:52 AM kakimir: if I do 32bit variable operations
08:52 AM kakimir: does it even matter if there is interrupt
08:52 AM kakimir: I mean context is restored when interrupt returns right?
08:52 AM rue_mohr: you would want to disable interrupts during your operations if they must not be interrupted
08:53 AM rue_mohr: yes, it wont corrupt values
08:53 AM kakimir: unless
08:53 AM kakimir: interrupt uses same variables
08:53 AM rue_mohr: you would want to disable interrupts during your operations if they must not be interrupted becuase their being used by the interrupt
08:53 AM rue_mohr: no, its not going to magically corrupt your program values
08:54 AM rue_mohr: you dont work with avr much yet do ya?
08:54 AM kakimir: I play mainly with cortex m0
08:54 AM rue_mohr: sweet
08:54 AM rue_mohr: whats your avr project?
08:54 AM kakimir: battery charger
08:54 AM kakimir: smart one
08:55 AM rue_mohr: ok, and why not stm32F103 ?
08:55 AM kakimir: price and size
08:55 AM kakimir: 5V power source
08:56 AM kakimir: *usb
08:56 AM kakimir: regulator is automatically more price and size
08:56 AM kakimir: *cost
08:57 AM kakimir: hey rue_mohr
08:57 AM kakimir: 16:52 < rue_mohr> no, its not going to magically corrupt your program values
08:57 AM kakimir: what do you mean?
08:57 AM kakimir: that there is logic to all this?
08:58 AM rue_mohr: well the f103 is cheaper than the larger avrs
08:59 AM kakimir: attiny20 or smaller
08:59 AM kakimir: small pkg
08:59 AM rue_mohr: mhm
08:59 AM kakimir: mmh package
08:59 AM kakimir: or smaller
08:59 AM rue_mohr: your not doing usb commumications with a tiny are ya?
08:59 AM kakimir: some simple charger detection
08:59 AM kakimir: no enumerating
09:00 AM rue_mohr: k
09:00 AM kakimir: at least I will try
09:00 AM kakimir: PWM, ADC, some passives
09:00 AM rue_mohr: yup, ok,
09:00 AM kakimir: rue_mohr: you think it can be done?
09:01 AM rue_mohr: sounds fine
09:01 AM kakimir: going thru USB BC detection sequences
09:01 AM kakimir: ex. SDP enumerating
09:02 AM rue_mohr: well, it'll depend how good a coder you are
09:02 AM rue_mohr: the tinys have quite limited memory
09:02 AM rue_mohr: and hardware
09:02 AM kakimir: yup
09:02 AM rue_mohr: I just wrote a serial reciever this weekend for one :)
09:03 AM kakimir: it's going to be tight
09:03 AM kakimir: rue_mohr: binary weight?
09:04 AM splud: A well-implemented state machine can do wonders for accomplishing things with low-resource ATTiny devices.
09:04 AM splud: I use ATTiny13A in a number of projects.
09:04 AM kakimir: attiny20 is my fav
09:04 AM splud: though admittedly, haven't had need to deal with USB with one
09:06 AM kakimir: technically it's just some analog sequencing
09:06 AM kakimir: USB BC
09:12 AM kakimir: set certain voltages / currents to data lines and read with ADC
09:12 AM rue_mohr: how fast is the t20?
09:12 AM rue_mohr: 9.6 on internal?
09:13 AM rue_mohr: or does that one have a pll
09:14 AM kakimir: I'll run it 1Mhz
09:14 AM kakimir: just default
09:14 AM kakimir: I think it can do 8 or so
09:14 AM rue_mohr: the t13 is 1.2/4.8/9.6Mhz
09:15 AM kakimir: 12Mhz
09:15 AM kakimir: 8Mhz
09:15 AM kakimir: and 1Mhz
09:15 AM kakimir: per voltage levels
09:16 AM rue_mohr: yes, but you said 5V, so your good
09:16 AM kakimir: I would go to 8Mhz max
09:16 AM kakimir: usb VBUS can drop
09:16 AM kakimir: and will
09:17 AM rue_mohr: avrs are ok with it
09:17 AM _ami_: antenna newbie here, i am doing some experiments with esp-now range.
09:17 AM rue_mohr: its a not a PIC, where the slightest bump or dip in power will lock it up
09:17 AM kakimir: AVR rules
09:17 AM rue_mohr: well, yes and no
09:18 AM _ami_: where should be the orientation of esp8266 pcb antenna for maximum reach?
09:18 AM kakimir: I looked PIC datasheet one day and I didn't understand a thing
09:18 AM rue_mohr: since microchip took over, it'll be going downhill,
09:18 AM kakimir: about that
09:18 AM rue_mohr: I'm bailing over to stm32 slowly
09:18 AM kakimir: what will happen and when?
09:18 AM rue_mohr: _ami_, good question
09:18 AM rue_mohr: kakimir, they will start changing the things that make avr appealing
09:19 AM rue_mohr: like free compiler support
09:19 AM kakimir: price?
09:19 AM rue_mohr: cheap programmer avialbility
09:19 AM kakimir: not a concern
09:19 AM rue_mohr: open documentation on programming standards
09:19 AM rue_mohr: if you have lots of money to pay microchip for using their processors
09:19 AM kakimir: as long as they roll old chips like they do now
09:20 AM rue_mohr: and want to choose them instead of someone like hitachi
09:20 AM rue_mohr: then its not a problem
09:20 AM rue_mohr: of course, after they have done all those thigns, community support will wither and die
09:20 AM kakimir: it has done that for years before it was even bought
09:20 AM rue_mohr: kakimir, they wont, did you see what they did between the 16F877 and the 16F877A ?
09:21 AM kakimir: I don't follow pic scene
09:21 AM _ami_: rue_mohr, you know the answer? :)
09:21 AM rue_mohr: they do not have a history of being friendly
09:21 AM kakimir: _ami_ google pcb antenna design and see what kind of beam pattern those have
09:21 AM rue_mohr: _ami_, no, there will be a distribution profile for that antenna, I would be curious to know what shape it is
09:37 AM kakimir: datasheet doesn't tell?
10:53 AM nabil_ is now known as nabil
10:56 AM nabil: https://imgur.com/a/qYm7aCT
10:56 AM nabil: .what is the significance of those two crossed circle in the center
10:56 AM nabil: ?
11:11 AM cehteh: thats where you put the pins when you hang it up to your corkboard
12:19 PM TechChristoph: hello
12:19 PM TechChristoph: which program is best vor avr-development
12:19 PM TechChristoph: i use a usbasp
12:19 PM TechChristoph: maybe to cheap i think
12:20 PM TechChristoph: or is avrdragon better ?
12:22 PM LeoNerd: I have some cheap usbasp things and also a Pololu v1
12:22 PM LeoNerd: The latter is a lot faster
12:24 PM TechChristoph: maybe linux is also not the standard for avr-development
12:24 PM LeoNerd: AVR is very easy on Linux
12:24 PM LeoNerd: apt-get install avr-gcc avr-libc avrdude; done :)
12:24 PM TechChristoph: it is, but i hav seen avrstudio
12:24 PM TechChristoph: wow that wa a blast
12:25 PM TechChristoph: but i haven't used it yet
12:25 PM LeoNerd: Depends if you want the fancy pointy-clicky mousegame IDE I guess
12:25 PM LeoNerd: I get on just fine without it
12:25 PM TechChristoph: ok, and code-completion ?
12:26 PM LeoNerd: What do you mean "code completion"?
12:28 PM polprog: iirc vim and emacs have some auto-complete plugins, but using them is kinda... weird
12:29 PM LeoNerd: I just use regular Ctrl-N completion for things like long function names when I can't be bothered to type it, but other than that I've never really had a problem
12:30 PM polprog: ctrl-n? you're using vim iirc?
12:30 PM LeoNerd: Yup
12:32 PM Rickta59: nice, i didn't even know that existed
12:33 PM Rickta59: does it know about the expected args with some other key sequence?
12:33 PM LeoNerd: Nope
12:34 PM Rickta59: still somewhat useful, thanks!
12:34 PM LeoNerd: I usually find I can either remember those, or just read the header file
12:34 PM LeoNerd: So it's never really a problem
12:34 PM Rickta59: i'm spoiled by eclipse hover and arg completion but i still use vi
12:34 PM Rickta59: and i crs at my age
12:36 PM Rickta59: i can only use emacs/vi because of muscle memory
12:36 PM polprog: LeoNerd: is this a native vim think or some script?
12:37 PM LeoNerd: Ctrl-N? that's just builtin
12:37 PM polprog: wow
12:37 PM LeoNerd: You might need to fiddle a couple of settings to make it behave nicely though
12:37 PM polprog: neat
12:37 PM LeoNerd: Iuse set wildmode=longest,list
12:38 PM polprog: another story, i was looking fo my openbsd install disc
12:38 PM polprog: i check all the drawers, desks and stuff
12:38 PM polprog: found 5 netbsd 7.* install discs for x86, amd64 and sparc64 (it never worked on the sparc, bootloader issue)
12:38 PM polprog: turns out the cd i was looking for was in the CD drive of said sparc...
12:38 PM polprog: lol
12:55 PM TechChristoph: exit
12:55 PM polprog: /quit
12:55 PM polprog: /quit
12:55 PM polprog: odd
12:55 PM polprog: doesnt work o_o
07:02 PM rue_mohr: hah
07:02 PM rue_mohr: polprog, /stay
08:20 PM [1]MrMobius is now known as MrMobius
11:21 PM day__ is now known as day
11:58 PM polprog: :P