#avr Logs

Nov 09 2018

#avr Calendar

01:10 AM logithack: i'm trying to modify an avr ping pong kit to work as a simple binary clock. starting from 00:00:00 works. now i'd like to implement an interrupt, allowing me to set the hours and minutes. however, the interrupt on INT0 doesnt react as intended.
01:14 AM logithack: consider this pdf: https://files.elv.com/Assets/Produkte/14/1448/144843/Downloads/144843_manual.pdf most of it is german, but the pictures will suffice.
01:14 AM logithack: page 6 shows K1 and K2, where a button is connected on my pong.
01:14 AM logithack: page 14 shows the rest of the important information
01:14 AM polprog: are you sure the interrupts are enabled?
01:14 AM polprog: sei(); and proper bits in the mask registers
01:15 AM logithack: when i flash the device, it starts counting from 0h 0m 0s onwards as intended. when i press the button, it erases the screen, waits 1 sec and starts again
01:15 AM logithack: however, my interrupt function looks like this:
01:16 AM logithack: https://pastebin.com/DJsSqUZf
01:17 AM polprog: _delay_ms(5000);
01:17 AM polprog: noooooo
01:17 AM logithack: this is just to see if it actually works
01:17 AM logithack: so if i press the button, i expect it to do nothing for 5 seconds, then continue at 0h 10m X seconds
01:18 AM logithack: where X is the number of seconds it displayed just when i pressed the button
01:18 AM polprog: is your minutes variable defined volatile?
01:19 AM logithack: nope, it isnt
01:19 AM logithack: let me check what that is (i've read it before, but never used it)
01:19 AM polprog: it neans that the compiler must read the variable from memory before every operation
01:20 AM polprog: more less.
01:20 AM logithack: let me try doing that, seems like thats more accurate for my purpose
01:21 AM logithack: do you only need to define them as volatile, or would you have to adapt functions from func(uint8_t) to func(volatile uint8_t)?
01:21 AM polprog: hmm
01:22 AM polprog: you shouldnt need to touch the functions
01:23 AM logithack: ah, its giving me a number of errors "expected 'uint8_t * {aka unsigned char *}' but argument is of type 'volatile uint8_t * {aka volatile unsigned char *}"
01:23 AM logithack: i thought i'd not use a normal int to save memory
01:23 AM polprog: oh. well, change the functikns as well
01:24 AM polprog: it takes the same amount of memory as a normal int in most cases
01:24 AM polprog: always in fact
01:25 AM logithack: okay
01:25 AM logithack: unfortunately, the interrupt still doesnt seem to work
01:26 AM polprog: what does your code look like?
01:26 AM polprog: the countdown function
01:28 AM logithack: https://pastebin.com/XjMpKPDL
01:28 AM logithack: init.h just defines the outputs and makes a few other defines.
01:28 AM logithack: init(); from init.c merely initialises the two shift registers with 0
01:29 AM logithack: sorry, with 1*
01:29 AM logithack: they shouldnt be relevant for this issue.
01:35 AM logithack: the strange thing is that it does seem to react when i hit the button. however, it doesnt execute ISR (int0_vect).
01:40 AM polprog: are you sure the isr isnt already defined somewhere else?
01:42 AM polprog: so your tick_sec functions works i suppose
01:43 AM logithack: the ISR function you mean?
01:43 AM polprog: no
01:44 AM polprog: void tick_sec(volatile int* hours, volatile int* minutes, volatile int* seconds) {
01:44 AM polprog: i mean this one
01:48 AM polprog: also my isr code waw always before main, im not sure if it matters
01:49 AM polprog: what are D0, D1 and D2... can you attach a led somewhere to make sure the isr is working by switching the led on or by some other means?
02:19 AM logithack: sorry polprog, i was afk
02:19 AM logithack: let me try setting my isr code before main
02:20 AM logithack: makes no change, but ill stick to it for conventional reasons
02:21 AM logithack: in case it is a convention
02:22 AM logithack: D0 and D1 seem to be unwired, so not in use
02:22 AM logithack: same for D" and D3, not sure what they are
02:23 AM logithack: the wiring diagram doesnt say anything about them
02:24 AM logithack: ill try to verify that the isr triggered by the button is working by switching on an led, sec
02:34 AM logithack: hm, ive changed main() to: https://pastebin.com/PqrQpdid
02:36 AM logithack: when i flash it, nothing happens on the led board, as expected
02:37 AM logithack: when i hit the button (press and release), the led blinks twice quickly, then one time longer, then its off agian
02:37 AM logithack: again*
02:37 AM logithack: the process takes less max. a second
02:37 AM logithack: the process takes max. a second* (cant write today)
03:03 AM polprog: did you debounce the button in hardware or software?
03:15 AM logithack: i didnt assemble the construction kit, i got it the way it is. if the button isnt already debounced in hardware, its entirely unbounced
03:15 AM logithack: cos i didnt care for it explicitly in software
03:15 AM logithack: your point could be the problem though
03:15 AM logithack: i'm reading about debouncing in software
03:16 AM polprog: they could have debounced it in software
07:09 AM [1]MrMobius is now known as MrMobius
07:43 AM cehteh: LeoNerd: could you produce the 328pb boards with 18.432Mhz osc? only 3 for evaluation
08:22 AM LeoNerd: cehteh: Yeah that should be possible - but I'd have to get the crystals (or you send). However, I do have some 14.7456 - that's another baud rate generator
08:25 AM cehteh: i'd prefer faster
08:25 AM cehteh: but its not extremely urgent
08:25 AM LeoNerd: Alrighty
08:26 AM LeoNerd: I'll see if I can get some
08:26 AM cehteh: how well do the board sell? would it make sense for you to build and offer more of 18.432Mhz?
08:26 AM cehteh: because that has exact baudrates up to 115200 baud
08:26 AM LeoNerd: Indeedy, as is 14.7456
08:26 AM cehteh: methings thats somehow a sweet spot for a 5V version
08:27 AM LeoNerd: I'm planning to do that in fact; just waiting on more boards
08:27 AM LeoNerd: Needs silkscreen for the ticky box. The resonator itself is too small for the frequency to be stamped on, so otherwise I forget
08:28 AM cehteh: and how much can you produce/how long can you offer support/availablitiy for these boards?
08:29 AM LeoNerd: 18.432 is good, but only for the newer chips. A lot of the older ones (a.g. ATtiny841) only go up to 16, which is where I use 14.7456
08:29 AM LeoNerd: I usually make them in batches of 6 boards as they come in 2x3 from oshpark
08:30 AM cehteh: so any more like 20pcs or so need some time in advance
08:30 AM LeoNerd: Eh, some time... oshpark is the slowest part of the chain there
08:30 AM LeoNerd: ~3weeks probably
08:31 AM LeoNerd: But I can do you a couple of test ones in the next couple of days hopefully
08:31 AM cehteh: ok
08:35 AM cehteh: ok a) can you order the crystals, makes no sense when i do (3 pcs for me only :D) and b) whats the price, for 3 for evalution and for more later on?
08:43 AM LeoNerd: I'll get back to you on that - am phone-typing from a bus currently ;)
08:45 AM vmt: what kind of boards are these?
08:47 AM LeoNerd: vmt: ATmega328PB breakout
08:47 AM cehteh: LeoNerd: ok .. anyway .. *reserved* ... we just decided we need them
08:47 AM LeoNerd: ;)
08:48 AM LeoNerd: https://www.tindie.com/products/leonerd/atmega328pb-development-board/
08:49 AM cehteh: LeoNerd: ping me when you have time, next small batch (4-6 pcs) are ours :D
08:50 AM polprog: if you're ordering so much, have you thought about other, higher volume board houses?
08:52 AM cehteh: is 6 pcs much?
08:53 AM cehteh: eventually we may make our own board, but this will become some machine which is only produced in small quantities, maybe it stays on a prototype board forever
09:05 AM LeoNerd: cehteh: http://home.leonerd.org.uk/local/screenie/silkscreen-18_4MHz.png
09:05 AM LeoNerd: New silkscreen just for you ;)
09:06 AM LeoNerd: Wondering if I should shrink the LED to an 0603, to make a little bit more space
09:06 AM LeoNerd: Actually it doesn't seem to make a lot of difference
09:07 AM cehteh: LeoNerd: do you have this DTR sends Reset to the controler line?
09:07 AM cehteh: arduino style
09:07 AM LeoNerd: Yup. Via a labeled cap on the back of the board - you can remove it if you don't want it
09:08 AM cehteh: imo you could leave the LED out. and for that reset line a solder brige (2 close pads) would be nice
09:08 AM LeoNerd: "C5" on the fourth photo on the product page
09:14 AM LeoNerd: cehteh: I'm guessing you're in the category of "folks annoyed by stupid 1930s legacy serial baudrates"
09:14 AM cehteh: LeoNerd: or you just leave the cap out for the ones we order
09:14 AM LeoNerd: Mmm.. I usually build stock in advance, but in your case for the 18.4 that won't be stock yet, so that's fine
09:15 AM cehteh: so how much could you make ASAP .. 4-6?
09:16 AM LeoNerd: Well currently I've no spare boards; they're all built up as 16 or 20. I -could- reflow a crystal off and do one at 18.4, but I don't have that crystal yet either
09:16 AM cehteh: apropos smaller LED .. i personally hate those, they give blind spots in the eye, i am fine with a huge diffuse led :D
09:17 AM LeoNerd: So ... it'll be sometime next week when I get that. Ideally I'd like to get another PCB run to have the silkscreen marking
09:17 AM cehteh: ASAP mean ASAP, not overnight :) when the new boards come next days its ok, you have to get the crystals too anyway
09:17 AM LeoNerd: Well.. ~2 weeks or so for boards
09:27 AM kakimir: is there a call to reset avr?
09:27 AM kakimir: there is no reset source flag for it
09:29 AM LeoNerd: Usual approach is to cli() then enable the WDT on shortest timeout
09:30 AM LeoNerd: WDT will get upset and reboot the CPU
09:31 AM kakimir: good
09:31 AM kakimir: nasty but good
09:32 AM LeoNerd: It's not pretty ;) Newer CPUs have a dedicated RESET instruction
09:32 AM kakimir: WDT can be changed on the fly can't it?
09:41 AM nabil_ is now known as nabil
09:46 AM cehteh: dont forget to disable WDT on boot, otherwise you'll be surprised
09:48 AM cehteh: what DCDC 24v->5V would you recommend for professional application (aka, not china trash, must be reliable, could cost a bit more) ... 100mA only
09:54 AM cehteh: https://www.reichelt.de/Wandler-bis-1-W/2/index.html?ACTION=2&LA=2&GROUPID=7248&SID=93W0Wpd6wQATUAAAMRUOwecbf365f0b01602dad974e80fb273720
09:54 AM cehteh: ... sounds good
09:55 AM LeoNerd: Right - am about to commit to copper and steel, unless you have any last changes to request...
09:55 AM LeoNerd: (actually maybe polyimide to start with)
09:55 AM cehteh: eh what?
09:56 AM cehteh: changes to the board?
09:56 AM cehteh: yes please include a 100mA DCDC 24V in 5V out .. thanks :D
09:57 AM LeoNerd: Uhmm... maybe not ;)
09:57 AM cehteh: haha
09:57 AM cehteh: ok
09:58 AM cehteh: no C5 ... 18.432Mhz ... thats the only change i really need, LED is meh .. dont care, the less it burns on my retina the better, but i have opaque tape :D
09:58 AM LeoNerd: I'll leave it at 0805
09:59 AM LeoNerd: Oh.. Hrm.. when I build these up, if I omit C5 then I won't be able to test optiboot
09:59 AM LeoNerd: I can use the ISP connector to test the board generally, so that'll be fine
10:01 AM LeoNerd: Righty - copper and polyimide now ordered :) I'll get some of the components ordered soon, though I know the copper is usually the slow part
10:14 AM cehteh: copper?
10:15 AM LeoNerd: The board
10:16 AM cehteh: how about the crystals?
11:01 AM LeoNerd: They'll only take a couple of days to arrive; they'll be in my next parts order
02:24 PM kakimir: whoops
02:24 PM kakimir: i had save calibration to eeprom in while(1) //debug
02:24 PM kakimir: luckily didn't make install it
02:30 PM [1]MrMobius is now known as MrMobius
06:11 PM LeoNerd: cehteh: I just found 3 boards I'd forgotten about, so I could build those up for you as soon as I get the crystals. They won't have the "18.4" option marked on silkscreen so you'll "just have to remember" that they're that frequency. But they'll work just fine
07:37 PM cehteh: LeoNerd: as long the boards cant read, the silkscreen doesnt matter
09:10 PM MrMobius is now known as [1]MrMobius
09:13 PM [1]MrMobius is now known as MrMobius
09:20 PM MrMobius is now known as [1]MrMobius
09:21 PM [1]MrMobius is now known as MrMobius
09:22 PM MrMobius is now known as [1]MrMobius
09:23 PM [1]MrMobius is now known as MrMobius
11:48 PM day__ is now known as day