#avr Logs

Mar 23 2017

#avr Calendar

12:25 AM z3t0: hi
12:28 AM z3t0: does a switch statement re-evaluate a volatile variable when checking for each case
01:17 AM daey_ is now known as daey
01:36 AM xentrac: z3t0: no
01:36 AM xentrac: it evaluates the expression in its parentheses exactly once; it is even safe to use expressions with side effects, like switch (*p++) { ...
02:27 AM vishwin60 is now known as vishwin
02:27 AM z3t0: what does ck stand for in 14ck + 65ms?
02:29 AM _ami_1: z3t0: clock cycle
02:30 AM z3t0: does that mean 14 ticks? _ami_1
03:17 AM Thrashbarg_ is now known as Thrashbarg
08:09 AM arij is now known as arij_work
08:16 AM ozzyBRG: hey folks! could you help me with programming atmega328 using usb asp programmer?
08:18 AM ozzyBRG: I can't communicate with atmega328 http://pastebin.com/etXydRE4
08:18 AM ozzyBRG: I'd like to use internal oscillator
08:21 AM ozzyBRG: http://pastebin.com/k0WUHECd
08:23 AM ozzyBRG: I've tried to update programmer's firmware using this tutorial https://tosiek.pl/usbasp-v2-0-warning-cannot-set-sck-period/ but it didn't fix the problem
08:24 AM ozzyBRG: Has anyone know how to run this atmega?
08:24 AM ozzyBRG: Btw, I've tried ATmega8 and it works correctly
08:27 AM ozzyBRG: I've updated programmer with the newest 2011-05-28 firmware...
08:41 AM rue_bed: show us the avrdude command your using
08:41 AM rue_bed: you prolly didn't get an option right
08:42 AM rue_bed: ozzyBRG,
08:42 AM rue_bed: I'm starting to get really worried about tom_L
08:44 AM ozzyBRG: rue_bed: I think I've fixed it. When I've ATmega328, which uses bootloader for external oscillator I can't get in run (burn new bootloader) without external oscillator, right?
08:47 AM elf_flux: Hi, I can't find any documentation on the xmega128a4u fuses
08:47 AM elf_flux: are fuse registers the same per family or so?
09:26 AM julius_: can somebody spot the problem why the led wont blink every second? https://bpaste.net/show/984ac818cca8 timer0, atmega328
09:28 AM rue_house: julius, whats the system clock?
09:30 AM Emil: julius_: while(1); is enough
09:30 AM rue_house: julius, interrupt rate will be the system clock, diveded by the prescaler, divided by the counts to overflow (256 or 65536)
09:30 AM Emil: Calling cli is unnecessary
09:31 AM Emil: And
09:31 AM Emil: you never set status anywhere?
09:32 AM Emil: mate do you even read your own code :D
09:32 AM rue_house: he flips in in the interrupt
09:32 AM Emil: ah
09:33 AM cehteh: haha :D
09:33 AM cehteh: well the code can be done much easier
09:33 AM Emil: Written silly, though
09:33 AM rue_house: but, thats not what he asked
09:33 AM cehteh: yes
09:33 AM rue_house: asked why its not 1hz
09:34 AM cehteh: so i suspect some error in the calculation of the frequency, F_CPU not set or so
09:34 AM rue_house: timer 0 is 8 bits
09:34 AM cehteh: yes
09:34 AM cehteh: 328p?
09:34 AM rue_house: 1024*256
09:34 AM rue_house: then *61
09:34 AM Emil: F_CPU doesn't affect anything else but _delay_*
09:34 AM cehteh: yes
09:35 AM rue_house: it looks like its almost set for 16Mhz
09:35 AM cehteh: eh has TIMASK a write control bit? cant remmeber rtfm
09:35 AM Emil: And eh
09:35 AM Emil: Why are you setting the led on every interrupt?
09:35 AM Emil: Line 30
09:35 AM rue_house: if its coded for 16Mhz, its prolly a problem where he's using a 8Mhz chineese 16Mhz crystal, or its set to the internal clock osc
09:36 AM Emil: mates :D
09:36 AM Emil: pls
09:36 AM Emil: It's not about the clock freq
09:36 AM rue_house: my answer is that the clock source isn't 16Mhz
09:37 AM Emil: Every interrupt he's setting the led on
09:37 AM rue_house: wtf?
09:37 AM rue_house: PORTD &= ~(1 << LED1);
09:38 AM rue_house: that puts the io pin low
09:38 AM Emil: 2017-03-23 16:06:12 +0200 < Emil> Line 30
09:38 AM Emil: rue_house: can you even into code?
09:38 AM * rue_house snickers
09:38 AM rue_house: looka dat...
09:39 AM rue_house: that wouldn't help
09:40 AM rue_house: arg, its garbage day!!!!
09:42 AM * rue_house races around collecting garbage
09:43 AM Emil: https://emil.fi/jako/kood/timerblink.c
09:43 AM Emil: https://emil.fi/jako/koodi/timerblink.c
09:44 AM Emil: Also you need inttypes or stdint.h
09:44 AM Emil: (inttypes is bloat, stdint is better)
10:13 AM JanC_ is now known as JanC
10:48 AM julius_: rue_house, 16mhz
10:50 AM julius_: rue_house, PORTD &= ~(1 << LED1); is used one before the while loop as far as i can see
10:50 AM julius_: to test if the led is connected and working i switch it on and off at the start
10:51 AM julius_: actually the led isnt blinking as all...cant see it at least
10:51 AM julius_: i bet the code is crashing before it ever reached the isr or just in the isr
10:54 AM julius_: rue_house, the crystal is working fine for bluetooth communication for example...so im guessing its a real 16mhz
10:55 AM cehteh: still not working?
10:57 AM cehteh: ah julius i see why :D
10:58 AM fnshem256: Hello everyone. I am requesting for help with atmega128. Anyone please
10:58 AM cehteh: and why di I have to RTFM for YOU? :)
10:59 AM Chillum: fnshem256: if you describe your problem you are more likely to get help
11:00 AM skz81: julius, unsure if someone answer you, but this PORTD |= (1 << LED1); at the begining of ISR turn on your LED, no ?
11:01 AM cehteh: .. i wonder, i was away and no one seen the error yet .. lets make it a quiz :D
11:01 AM cehteh: skz81: that part of the code is ok ... :D
11:01 AM Emil: julius_: did you read the comments?
11:01 AM Emil: or look at my version?
11:02 AM Emil: cehteh: wtf. Line 30 definitely is not ok
11:02 AM cehteh: ok i dint checked that .. but there is a more servere error in the initialization
11:02 AM fnshem256: thank Chillum: I am having trouble with writing a list of parameters to eeprom. The size of the list is dynamic so i cant use an array. I would like to store this list in eeprom. For example list=a, b,c,d,e where a, b... are strings
11:02 AM Emil: what's that?
11:02 AM cehteh: which craps everything out
11:03 AM Emil: what's that?
11:03 AM cehteh: CSxxx is in TCCR0B not TCCR0A
11:04 AM Emil: lol
11:04 AM Emil: true
11:04 AM cehteh: would be nice if these bit definitions had a typesafe layer on top
11:04 AM skz81: <julius_> i bet the code is crashing before it ever reached the isr or just in the isr >> hum, a crash would mean a reboot, so you should it blink a bit
11:05 AM cehteh: in the isr he could just togglke by writing to PIND
11:05 AM Emil: julius_: mate, avrs dont crash
11:05 AM skz81: (but maybe not with a "clean" 50% duty cycle)
11:05 AM cehteh: avrs crash .. jumping to reset vector when one does something very rong
11:05 AM cehteh: w
11:05 AM Emil: cehteh: that, too
11:05 AM skz81: <Emil> julius_: mate, avrs dont crash >> hum illegal opcode, undefined ISR called, etc... means reboot AFAIK
11:05 AM cehteh: yes
11:06 AM Emil: no. That is defined behaviour
11:06 AM Emil: they do exactly as told
11:06 AM cehteh: i seen many such bugs. people wondered why their code doesnt work, but in fact it just was in a reboot loop
11:06 AM cehteh: by that definition any crash is defined behavior
11:06 AM skz81: <Emil> they do exactly as told >> SIGSEGV is well defined too. But still a "crash"...
11:07 AM Emil: skz81: your fault if you dolt catch it
11:07 AM skz81: an illegal opcode ?
11:07 AM Emil: but really, avrs do exactly as told
11:07 AM skz81: ho, you mean catching SIGSEGV ???
11:07 AM Emil: there is no abstraction layer
11:07 AM cehteh: sigsev on your linux box is doing well defined behavior as well
11:08 AM julius_: cehteh, no ideas what to change so far
11:08 AM cehteh: julius: TCCR0A is wrong
11:08 AM julius_: just reading the chatter...one sec
11:08 AM Emil: julius_: do you read what we write?
11:09 AM cehteh: you need to write the CSxx things into TCCR0B
11:09 AM Chillum: fnshem256: there are many ways to turn a data structure into a string of bytes to be saved
11:09 AM Chillum: as many ways as there are hairs in my nose
11:09 AM Emil: And my link above has optimised code
11:09 AM Chillum: this is more of a C++ problem than an avr problem
11:10 AM Emil: Hey share yout ascii decimal printing code
11:10 AM julius_: ah crap
11:10 AM skz81: Chillum, fnshem256 >> go for a tiny JSON implementation ?
11:10 AM julius_: cehteh, thanks
11:11 AM skz81: julius, and remove the first line of your ISR BTW
11:11 AM julius_: skz81, isnt reboot the same as "crash"? i mean the same end result
11:11 AM Chillum: json is a bit bulky for the constraints of eeprom
11:11 AM julius_: skz81, yes that was for testing
11:11 AM Emil: https://emil.fi/jako/koodi/timerblink.c
11:11 AM cehteh: just use the worst case string len as array
11:11 AM skz81: julius, yes that what we're saying :)
11:12 AM cehteh: and when you want to write to eeprom frequently then you need to mitigate wear
11:12 AM julius_: skz81, no thats what im saying
11:12 AM cehteh: fnshem256: ^^ with checksum and generation counter
11:13 AM Chillum: fnshem256: better to talk here than in private message, you will get more help in public
11:13 AM Chillum: I am only so wise after all
11:13 AM Chillum: very wise, but finitely so
11:13 AM Chillum: I used to think I was infinitely wise, but then I wised up
11:14 AM fnshem256: thank you, i was a bit overwhelmed
11:14 AM Emil: uncountably or countably?
11:15 AM Chillum: fnshem256: might be useful: https://github.com/francc/tinypacks though a custom solution might work better for your use case
11:15 AM Chillum: what is your use case?
11:18 AM Emil: I'd buy a spi flash chip
11:18 AM julius_: cehteh, i looked over that code at least 20 times but the timer information i got from different tutorials...shouldnt have mixed
11:18 AM Chillum: microsd cards are really easy to use on an esp8266
11:19 AM Chillum: and the 1-8Mb ones are really cheap on ebay
11:19 AM Chillum: they ones that come with cameras but only hold like 3 pictures
11:19 AM Chillum: they are perfect for microcontroller extended storage
11:19 AM Chillum: you can even solder them right in instead of using a connector if you are careful
11:19 AM Emil: Hmm. You still need a holder for them
11:19 AM Chillum: not if you are good
11:20 AM Emil: But in that case I'd just buy flash chips
11:20 AM Chillum: though the SD to microSD adapter that comes with every card is probably a better candidate to solder
11:20 AM Emil: Though
11:20 AM Emil: if you need to preload data
11:20 AM Emil: then sd is pretty good
11:20 AM Chillum: or offload
11:21 AM Chillum: I soldered pin header to a SD microSD adapter
11:21 AM julius_: you use that for extra ram?
11:21 AM Chillum: been using it for years
11:21 AM cehteh: julius: Datasheet
11:21 AM fnshem256: Chillum: I have a number of sensors. User enters a list of sensors separated by commas. So i would like to store this list in eeprom. Thats my use case
11:21 AM Chillum: not ram, storage space
11:21 AM Emil: hmm, trueish. I'd just push through uart
11:21 AM julius_: cehteh, yes...would probably been better
11:21 AM cehteh: no
11:21 AM Chillum: fnshem256: assign each sensor a number
11:21 AM cehteh: that *IS* better
11:21 AM Chillum: store the numbers
11:21 AM julius_: ok
11:21 AM Chillum: or assign each one a bit
11:22 AM Emil: fnshem256: and what is your problem?
11:22 AM Chillum: and build a byte or two out of the bits
11:22 AM Chillum: store the bits
11:22 AM cehteh: i was away, when i came back and seen that the problem was still not solved it took me 15 seconds to look that up in the datasheet
11:22 AM julius_: cehteh, i wasnt concerned with the register names...thought they were right
11:23 AM Emil: There's your problem
11:23 AM cehteh: your thought was wrong :D
11:23 AM julius_: xrue
11:23 AM julius_: t
11:25 AM julius_: anyway, yesterday i used two power supplys, one to power the avr with 5v and another 12v supply for a 10w lead. i did not connect the ground circuits of both power supplys which resulted in the led flickering....but when i measured resistance between drain and source from the mosfet the led went on and current went up....how could the meausrement improve the ground connection?
11:25 AM fnshem256: Emil: my problem is how to store this list in eeprom. Because so far i can store a string but then with this string i know its size in advance. However i have been using a linked list which is a dynamic data structure. I am stuck on how to write this data to eeprom
11:26 AM fnshem256: Emil: A linked list whose size i dont know and i dont know how many byes it will take up
11:26 AM julius_: fnshem256, (beginner talking) i believe what chillum said was to save every information in its own byte so you know that the next number is one byte apart
11:26 AM julius_: assuming that the information fits into a byte
11:26 AM Chillum: I just meant don't store a list of text strings representing a finite list of items
11:27 AM Chillum: if it is just a list of sensors then you should have no problem giving each one its own byte identifier
11:27 AM Chillum: unless you have more than 256 sensors, then use 2 bytes
11:28 AM Chillum: just make a table in PROGMEM that maps the sensors to numbers and back
11:28 AM Emil: julius_: >did not connect ground
11:28 AM Emil: wtf
11:32 AM Emil: fnshem256: is your data structure dynamic in size?
11:33 AM Emil: or just that you have x known size blocks
03:30 PM arij_work is now known as arij
06:02 PM postmodern: i'm looking for an software serial implementation that can support reading from multiple ports
06:03 PM postmodern: most examples i've found only support a single hardcoded RX pin
06:18 PM Lambda_Aurigae: you want a soft-uart?
06:18 PM Lambda_Aurigae: not using the built in hardware uart?
06:25 PM Emil: Well
06:25 PM Emil: I mean
06:26 PM Emil: One could in theory receive and send on 8 channels at the same time :D
06:26 PM Emil: quite easily
06:30 PM cehteh: as long you have time to handle the data, and maybe space to buffer
06:41 PM Emil: Space nor time are really issues
06:41 PM Emil: especially if 9600 baud