#avr Logs

Jan 22 2018

#avr Calendar

12:15 AM polygon: nuxil: malloc does not fill 0
12:18 AM polygon: calloc does
12:24 AM _ami_: nuxil, malloc() & memset(0) === calloc()
12:33 AM rue_: p = malloc (nelem * elsize);
12:33 AM rue_: if (p == 0)
12:33 AM rue_: return (p);
12:33 AM rue_: bzero (p, nelem * elsize);
12:34 AM rue_: or memset depending
12:35 AM rue_: memset(ptr, 0, nmemb * size);
12:35 AM rue_: ok supper
12:36 AM rue_: rue_, what do you want for supper
12:37 AM rue_: I want to be a robot
12:37 AM rue_: not helping
12:37 AM rue_: choices are:
12:37 AM rue_: rice and mushroom soup
12:37 AM rue_: and...?
12:37 AM rue_: mmm, yea.. about that....
12:38 AM rue_: are you saying were out of everything?
12:38 AM rue_: well.....
12:38 AM rue_: we must have something else
12:39 AM rue_: c ..atfood?
12:39 AM rue_: cmon think
12:39 AM rue_: pasta?
12:40 AM rue_: is there any mac and cheese?
12:40 AM rue_: ANY????
12:41 AM nuxil: pizza
12:41 AM nuxil: polygon, _ami_ yea i see now
12:42 AM _ami_: rue_, bzero() is obsolete now
12:46 AM Emil: _ami_: no
12:46 AM _ami_: it is. Emil check it again.
12:46 AM Emil: _ami_: like I said, a guy asked in ##c and I just thought I could do it quickly and nicely
12:46 AM Emil: _ami_: context was still your higlight ;)
12:47 AM _ami_: oh, i thought u r talking abt bzero :D
12:47 AM _ami_: sorry
12:47 AM Emil: np
12:47 AM _ami_: hmm, ok
12:47 AM Emil: _ami_: it works nicely, though
12:48 AM Emil: Shows how easy it is to build synchronous interfaces :D
12:50 AM rue_: so I made like 600 breadboard jumpers yesterday
12:50 AM rue_: there is a blister on my finger
12:50 AM rue_: and a good sized, heavy box of jumper wires
12:54 AM Emil: :D
12:54 AM Emil: Nice one
01:34 AM _ami_: is it possible to control the voltage of those cheap boost dc-dc converter via pwm? e.g. LM2577
01:34 AM _ami_: connect the output to mosfet and supply pwm to it?
01:35 AM _ami_: can be used as diy bench power supply?
01:36 AM _ami_: ah, if mcu is not PWMing then high voltage would fuck the component
01:37 AM _ami_: may be a LM317
01:43 AM Casper: if it have an external Vref then it could be used with PWM and a low pass filter
01:43 AM Casper: if it use an internal one, no good
01:44 AM Casper: however there is some feedback tricks that can be used maybe
02:11 AM _ami_: Casper, thanks
02:12 AM _ami_: Casper, i could remove that potentio-meter from board and provide pwm to it to control the output? i think it is connected to FEEDBACK
02:12 AM Casper: it's most likelly used as a voltage divider
02:13 AM Casper: so not really
02:13 AM Casper: however, you could use an opamp in differential mode to offset the voltage...
02:15 AM _ami_: Casper, http://www.microchip.com/forums/m688260.aspx
02:18 AM Casper: that can also work
02:18 AM Casper: with limited control
02:19 AM Casper: and will also increase the error on the output proportionally
02:19 AM Casper: but can still work, depending on the range you need and precision needed
02:21 AM _ami_: i would like to have 0 to 24v range in my diy power supply.
02:22 AM _ami_: thinking to add a touch panel (since i have too many of them :D )
02:22 AM _ami_: i don't want potentiometer to control the output
02:23 AM _ami_: if current limit control can be done then its better.
02:23 AM Casper: you may want to look for some programmable IC, or some digipot
02:23 AM Casper: also, many regulator do NOT go down to zero
02:24 AM _ami_: min 1.25v is okay in my case.
02:29 AM _ami_: Casper, good idea. i should order those digipots. i think i might have 1 or 2 lying somewhere.
02:30 AM Casper: just beware about their voltaghe on the pot side
02:30 AM Casper: often it need to be within the supply limit...
02:30 AM Casper: which can cause an issue in this exact application...
02:30 AM _ami_: yes
02:30 AM Casper: well, bed time, nite
02:31 AM _ami_: Casper, nn! :)
02:31 AM Casper: and one anti-inflamatory pills down...
02:31 AM Casper: I might have exagerated a bit with my ankle tonight...
02:31 AM Casper: (twisted it last monday... badly)
02:32 AM _ami_: while playing?
02:32 AM _ami_: or doing workout"
02:32 AM _ami_: ?
02:33 AM Casper: even more stupidly...
02:34 AM Casper: we got a snow storm.... I cleaned the front of the car to the street with the snow blower... then went in the car, drove it to a side street. On my way back I tought: do I jump over the snowbank? or walk in the street. The snowbank is too high and wide, I'll walk in the street.
02:35 AM Casper: did one more step, foot slipped
02:35 AM Casper: then hit some harder snow, stopped tight there... and bent inward...
02:35 AM _ami_: Casper, ah! crap!
02:36 AM Casper: "crap" is almost the sound it made
02:36 AM _ami_: damn, your actions were like my kid actions. :P he likes to crush snow on the road.
02:36 AM Casper: the snowblower was running at full speed at about 50ft from there, I had my in-ear earphone, which is -20db noise isolation... and I hear the CLAK noise it made
02:36 AM _ami_: he does all the time whenever he go out with me. i have to hold him tight when he does tha.t :)
02:37 AM Casper: thing to know: the day before, we got rain, which turned into freezing rain then in snow
02:37 AM Casper: so there was a layer of ice under the snow
02:37 AM * _ami_ its raining/now right now in Seoul.
02:37 AM _ami_: raining/snow*
02:37 AM Casper: the city bus pass there... I slipped in the track, and hit a patch that was stuck
02:38 AM _ami_: terrible
02:38 AM _ami_: no fracture bones?
02:39 AM Casper: nothing broken
02:39 AM Casper: https://i.imgur.com/0yninGw.jpg <=== that much snow
02:39 AM Casper: dosen't look as bad on the pic however
02:40 AM _ami_: wow, thats a lot
02:40 AM _ami_: canada right?
02:40 AM Casper: yup
02:41 AM _ami_: we would have terrible cold this week. could go -17C :(
02:41 AM Casper: https://i.imgur.com/W3HygiN.jpg
02:41 AM Casper: only -17?
02:41 AM Casper: we got -27 + wind
02:41 AM _ami_: wow!
02:42 AM Casper: currently it's -8°C
02:42 AM Casper: so.... warm?
02:42 AM _ami_: :)
02:42 AM _ami_: its 1C here now but would start going down from today
02:42 AM Casper: https://i.imgur.com/PZjG9h8.jpg
02:43 AM _ami_: will reach -12C today's night
02:43 AM _ami_: temp here fluctuates a lot here. 18C fluctuation sometimes
02:44 AM Casper: same
02:44 AM Casper: heck.... we got +8°C and 2 says later it was -25°C
02:44 AM _ami_: thats a lot. wow!
02:45 AM _ami_: 33C
02:45 AM Casper: it was exceptional however
02:45 AM Casper: we got hit by heat, followed by cold...
02:46 AM * _ami_ hates cold. likes his native country weather more. :D
02:46 AM Casper: I also hate cold, but I actually hate more the heat
02:47 AM Casper: +28 + humidity = I am dieing
02:47 AM Casper: well, sleep time
02:48 AM _ami_: one thing i like about winter is that you get good sleep. usually true in my case.
02:48 AM _ami_: Casper, nn! tc
07:29 AM polprog: is there some library for stm32 that is similar style to avr libc?
07:30 AM revdns: Hello everyone! I have a question, i have structure where i defined controllers and views, but this structure saving in RAM. Is there any chance to save it on flash memory ?
07:31 AM polprog: revdns: PROGMEM http://www.nongnu.org/avr-libc/user-manual/pgmspace.html
07:33 AM revdns: But whenever i want to use it i need to copy this into RAM ?
07:33 AM polprog: yes, you use one of the macros
07:34 AM revdns: polprog, are You from Poland ? :)
07:34 AM polprog: yeah, how dod you know ;)
07:34 AM polprog: did*
07:34 AM revdns: Hehe, bo masz pol przed nickiem i tak mi sie skojarzylo :)
07:34 AM polprog: no racja ;)
07:35 AM revdns: Mialbys dla mnie sekunde na priv?
07:46 AM nohitzwork: polprog: no
07:47 AM nohitzwork: newlib is commonly used as C library
07:47 AM nohitzwork: with arms
07:55 AM polprog: nohitzwork: im looking at libopencm3
08:08 AM gruetzkopf is now known as gruetzkop
08:08 AM gruetzkop is now known as gruetzkopf
08:24 AM revdns: Mates, I have array of structs saved into PROGMEM, how can I read whole structure?
08:25 AM cehteh: read as in copy to ram? or access struct members as if progmem is flash?
08:27 AM revdns: cehteh: I have multiple structs in array and saved into progmem, i writing read function that get me a whole structure from progmem into ram and i can access like to structure members
08:27 AM revdns: Not individual member of struct but whole struct from array
08:28 AM cehteh: so whats the problem?
08:28 AM revdns: When i do return (Mode)pgm_read_byte(&modes[mode_active]);
08:28 AM revdns: I get error: no matching function for call to 'Mode_t::Mode_t(uint8_t)'
08:28 AM cehteh: eww c++ :D
08:30 AM cehteh: http://www.nongnu.org/avr-libc/user-manual/group__avr__pgmspace.html
08:30 AM cehteh: you can use the memcpy from there to copy the struct into ram, then access will ne 'normal'
08:32 AM revdns: cehteh: Okey i will try it, thanks!
08:33 AM polprog: hmm memcpy, interesting approach
08:34 AM cehteh: memcpy_P of course
08:35 AM cehteh: and it'll prolly mess up with C++ non pod datatypes, glhf
09:02 AM ac_slater: hey guys, this MIGHT not be the best channel for this question, but I have an AVR device that has rs232 and rs485, but I need to talk to an rs422 device
09:02 AM ac_slater: I couldn't find a nice and small IC anywhere that can do some conversion
09:02 AM ac_slater: not sure if such a thing exists
09:03 AM LeoNerd: Those are sortof separate things, let me explain
09:03 AM ac_slater: LeoNerd: I know the difference between rs232/rs485 and rs422
09:03 AM polprog: maxim does some differential drivers
09:03 AM ac_slater: but only a bit
09:03 AM LeoNerd: By "RS-232" do you just mean it has an async serial port, or do you mean it has the level -9/+9 converter in it?
09:04 AM LeoNerd: RS-422 and RS-485 are differential pair systems for carrying async serial. 422 is full-duplex, 485 is half
09:04 AM ac_slater: LeoNerd: it's just a usart port, it's actually TTL
09:04 AM LeoNerd: Righty
09:04 AM ac_slater: I'm working with a AVR32 UC3C, sorry I know this channel is for AVR8 :(
09:04 AM LeoNerd: Soyeah, if you want to talk RS-422 you just need to put a full-duplex line driver/receiver on the front of it
09:04 AM LeoNerd: Maxim make several, for example
09:08 AM ac_slater: LeoNerd: damn, I'm having bad luck finding any
09:09 AM polprog: https://www.maximintegrated.com/en/products/interface/transceivers/rs-485-rs-422-transceivers.html
09:09 AM LeoNerd: https://www.maximintegrated.com/en/products/interface/transceivers/rs-485-rs-422-transceivers.html
09:09 AM LeoNerd: ... snap
09:09 AM polprog: hehe
09:10 AM ac_slater: wow there are like ~50
09:10 AM ac_slater: (55)
09:10 AM LeoNerd: Also the parametric search https://para.maximintegrated.com/en/search.mvp?fam=rs485&hs=1 with 'duplex' set to Full or Full/Half
09:11 AM ac_slater: so can most of these be connected to my usart?
09:11 AM ac_slater: and should I configure that usart as rs232 mode or rs485 mode?
09:11 AM LeoNerd: Yah; they're TTL to RS-422 converters
09:11 AM ac_slater: I'm such a newbie with this
09:11 AM ac_slater: awesome!
09:11 AM ac_slater: thanks
09:11 AM polprog: this reminds me t o do some work today and try rs485
09:12 AM LeoNerd: You probably want to leave it in 232 mode; I'd suspect that "485 mode" on an MCU UART means that it will control some sort of transmit-enable output pin, for handling the half-duplex mode of a converter
09:12 AM LeoNerd: Whereas the entire difference between 485 and 422 is the half-vs-full duplex
09:12 AM ac_slater: yea
09:12 AM ac_slater: I agree
09:12 AM ac_slater: right right
09:12 AM ac_slater: thanks!
09:15 AM ac_slater: actually, I couldnt find any that specifically said TTL input. This is the only one that includes "TTL" in name https://www.maximintegrated.com/en/products/interface/transceivers/MAX14890E.html
09:16 AM day: is there an recommendable/easy to use dfu flash bootloader atxmega firmware?
09:16 AM LeoNerd: I don't think many will use the phrase "TTL", it's more just logic level
09:16 AM LeoNerd: The word "TTL" around serial lines is really just shorthand for "not the -9 or +9 V converted RS-232 levels"
09:17 AM LeoNerd: I.e. logic level
09:17 AM ac_slater: right, I went through a couple days of head-scratching to understand between TTL and true rs232
09:18 AM LeoNerd: "TTL" (i.e. logic level) idles/space at logic high, mark at logic low; a real RS-232 connection swings between -9V and +9V. Well, at least 9. sometimes 12 or 15
09:19 AM ac_slater: LeoNerd: yea I've had some 15v rs232 lines
09:19 AM ac_slater: very scary to have those around low voltage MCUs :0
09:19 AM ac_slater: ;)
09:19 AM ac_slater: also, LeoNerd, what about this? https://www.mouser.com/ProductDetail/Texas-Instruments/SN75ALS191DR?qs=sGAEpiMZZMumM9SKmFWhKjrt1xkyh%2ffHw0p4aSvqlKc%3d
09:20 AM LeoNerd: That's just an output driver
09:20 AM LeoNerd: Not a receiver; you'd need something else for receiving
09:21 AM ac_slater: oh I gotcha
09:21 AM LeoNerd: https://www.mouser.co.uk/Semiconductors/Integrated-Circuits-ICs/Interface-ICs/RS-422-Interface-IC/_/N-6j75f?P=1z0sogo
09:22 AM LeoNerd: (if filter selections make it across URL copypaste) - that's filtered for "Transceiver"
09:23 AM ac_slater: yup thanks!
09:23 AM ac_slater: Alright, LeoNerd I think this is it https://www.mouser.com/ProductDetail/Texas-Instruments/SN75C1168PWR?qs=sGAEpiMZZMumM9SKmFWhKjrt1xkyh%2ffHpyx%2faHx4Suw%3d
09:24 AM LeoNerd: It's a little overkill but yes that would do
09:25 AM LeoNerd: That's got two drivers and two receivers, so you can use it for the main data pair and a pair of handshaking lines as well (e.g. CTS/RTS)
09:25 AM LeoNerd: If you don't need that I expect you'll find a smaller 8pin device that just has one driver and one receiver
09:25 AM ac_slater: yea you're right
09:25 AM ac_slater: thats awesome
09:25 AM ac_slater: thanks LeoNerd
09:30 AM ac_slater: LeoNerd: find anything terribly wrong with this? https://www.mouser.com/ProductDetail/Texas-Instruments/DS89C21TMX-NOPB?qs=sGAEpiMZZMumM9SKmFWhKrwDSSHinNX%2fNAbbzXNKMME%3d
09:31 AM ac_slater: I think it looks fine, but I cant tell if it can support 57600 baud... I think it can
09:33 AM LeoNerd: Yeah that looks like the standard 8pin packaging format for that kind of chip
09:33 AM ac_slater: awesome!
09:33 AM LeoNerd: It says it supports up to 2Mbaud, so I doubt it'll have a problem with 57.6k ;)
09:33 AM ac_slater: LeoNerd: you've helped me so much, I really appreciate it!
09:33 AM ac_slater: yea I just saw that ;)
10:08 AM polprog: hmm. looks like termios has a tcdrain() which will wait until the send buffer is empty
10:08 AM polprog: now if i write a set_rts() and clr_rts() functions, i should be able to use this 485 driver with my pc's serial port
10:22 AM polprog: odd
10:22 AM polprog: when i set rts with ioctl, dtr goes up as well
10:23 AM polprog: what's the idle state for those lines? logic low or high? (-9 or +9) ?
11:14 AM polprog: serial port wiggler is getting closer to be a usable 485 transceiver
11:14 AM polprog: i can wiggle RTS
11:14 AM polprog: ill try DTR now
11:27 AM polprog: dtr works ask well
11:50 AM polprog: https://puu.sh/z7ePV/48e8b12d45.png
12:05 PM jragon: I'm trying to figure out what the best way to avoid floats is when trying to scale a graph. The graph scale could be fractional. Unfortunately the scaling operation is done a lot (each time when drawing the graph). I could use a float but I'm not sure worried about the performance loss (probably premature optimization), since I redraw the graph up to 50Hz
12:07 PM jragon: Here's the get_y function: https://www.paste.org/90150, scale is currently 1 or greater
12:08 PM jragon: I suppose when I create the scale var I could multiply it by 100 and then divide by 100 in the function
12:10 PM polprog: that would be fixed point effectively (i think) and is a rather good solution
12:11 PM jragon: Fixed point as in there's always 2 decimal places?
12:12 PM cehteh: whatever decimal places you want
12:12 PM polprog: as in you are dealing with a 1/100 of your unit. so 1 lsb in your case is 1/100 unit
12:12 PM cehteh: but if you dont need it for output, then using power of 2 factors might become simpler
12:12 PM polprog: yes
12:12 PM polprog: also the division and multiplication will be less resource intensive
12:12 PM jragon: Okay great.
12:13 PM jragon: Unfortunately the scales tend to be fairly unpredictable
12:13 PM jragon: It's based on the graph_height and the max y value
12:13 PM cehteh: 1/128 1/1024 or whatever, think about your corner cases, whats the smallest (underflow) or biggiest (overflow) condition, can you completely avoid that? or need to handle it
12:14 PM polprog: of course you can use [u]int_16t or 32 or 64 if you need
12:14 PM jragon: How would you recommend implementing the divisor? I would just hard code the / by 100. Maybe I could define SCALE_DIVISOR
12:14 PM polprog: defines are always better than magic numbers
12:15 PM jragon: Great. Will do :)
12:15 PM jragon: cehteh: What do you mean by overflow and underflow?
12:15 PM cehteh: maybe you can optimize division out, or at least reduce it
12:16 PM cehteh: floats have a somewhat wide range, just getting more inprecise at huge/small numbers
12:16 PM polprog: i think avrs dont even have a div opcode (at least those that i use dont have)
12:16 PM jragon: mm, with a left shift? This is only possible if the scale is a power of two though
12:16 PM cehteh: integer just over/underflow and give errorneus results, you need to handle that
12:16 PM polprog: its possible with every number
12:18 PM cehteh: ideally you can do power of 2 math, sometimes even leave division out, but note somewhere that your scale increased
12:27 PM jragon: Okay thanks guys, I've got some learning to do :)
12:30 PM polprog: division on avrs: don't. :P
12:31 PM gruetzkopf: basically yes
12:56 PM polprog: rigol probe cables are just awful
12:56 PM polprog: still as hell
12:56 PM polprog: stiff*
12:56 PM polprog: i need to get some good probes
12:58 PM cehteh: haha first we saied no floats, now we are already at no division :D
12:59 PM cehteh: next time, dont use AVR
12:59 PM cehteh: division is sometimes avoidable, but if you have to use it just do
01:00 PM polprog: we should write a turing amchine hal and then write all programs for that machine
01:13 PM jragon: Thanks guys! The scaling is working well now :) Here it is in action: https://streamable.com/g9pdf the yellow trace is read directly from the ADC and the blue one is just a sine wave
01:15 PM polprog: music playing in the workshop, just like it should be ;)
01:15 PM polprog: whats that display module?
01:16 PM jragon: It's a ili9340
01:18 PM jragon: The stuff around it is just a breakout board type thing. One of my professors created a board for the Atmega644p. It's a nice exercise actually, they give us all the PCB and we have to solder on all the components. Making the display breakout was the worst! The pin spacing is awful!
01:21 PM polprog: oh. small pitch i guess?
01:21 PM polprog: or flex cable?
01:22 PM jragon: On the back it's some flex cable. The spacing is about o.5mm when it's soldered to the board
01:23 PM jragon: Usually the headers fit right over the board, but since the control usually uses PORTA and I need that for the ADC I've had to use some ribbon cable to connect it up which means the display flops all over the place
01:28 PM polprog: hmm
01:59 PM polprog: https://twitter.com/polprogpl/status/955528934569005056
02:01 PM antto: polpro gpl
02:01 PM * antto avoids..
02:35 PM Emil: please unfuck the topic
02:35 PM Emil: Tom_L or someone
02:43 PM Tom_L: what's wrong with it?
02:44 PM Tom_L: what would you like it to say?
02:59 PM Emil: remove -- #define SetBit(BIT, PORT) (PORT |= (1<<BIT)) #define ClearBit(BIT, PORT) (PORT &= ~(1<<BIT))
03:00 PM Emil: and probably even the wormfood and engbedded
03:17 PM polprog: or move the links before the defines
03:45 PM antto: Emil >:(
03:45 PM antto: fusecalc is useful!
03:51 PM polprog: nearly done my 485 driver
04:17 PM Emil: antto: and you can find it with "avr fusecalc"
04:17 PM Emil: it doesn't have to fucking be in the topic
04:20 PM polprog: https://puu.sh/z7pdj/9f53694a3c.jpg https://puu.sh/z7pdO/79cc544c5e.png RS 485 working
04:22 PM Emil: beautiful
04:23 PM polprog: thank you
04:36 PM polprog: night
04:40 PM polygon: hello
04:42 PM polygon: [18:46] <_abc_> http://www.avrfreaks.net/forum/differences-between-atmega8888pa-etc I am writing some code to be compatible with v-usb [18:46] <_abc_> there are the processor definitions to deal with, it is hard hard. - want atmel.com?
04:42 PM polygon: i have a mirror
04:53 PM polygon: [07:48] <rue_> there is a blister on my finger - reminds me of when i tested one of my first switched mode power supplies without heat-sink, and i touched a mosfet's back to see if it is hot. It was kind of hot, my fingerprint got imprinted on the tin plating ;)
05:04 PM polygon: [21:57] <Emil> remove -- #define SetBit(BIT, PORT) (PORT |= (1<<BIT)) #define ClearBit(BIT, PORT) (PORT &= ~(1<<BIT)) - agreed that is not pro
05:50 PM nuxil: so macros. :)
05:50 PM nuxil: i have this
05:50 PM nuxil: #define button_x_on (x,y,z,b) ((x==1) && (y==b) && (z==0)) ? 1 : 0
05:50 PM nuxil: and i can use it like if: (button_x_on(val[0], val[1], val[2], 3) ) { foobar(); }
05:50 PM nuxil: but is it possible to rewrite the macro so it take an array as argument ?
05:51 PM polygon: sure
05:51 PM nuxil: yeah?
05:51 PM polygon: macro does not care
05:51 PM nuxil: practical example pls :p
05:52 PM polygon: #define distanceofp3ds( p1, p2 ) ( \ (__typeof__ ( (p1).x ))sqrt( sqr( (p1).x - (p2).x ) + \ sqr( (p1).y - (p2).y ) + \ sqr( (p1).z - (p2).z ) \ ) \ )
05:53 PM nuxil: so i just do button(x,b) (x[0] == 1) && x[1] == y ....
05:53 PM nuxil: p3d's sounds like a 3d format O2 uses :p
05:53 PM nuxil: == b .
05:54 PM polygon: typedef struct { double_t x, y, z; } p3d_t; // structure holding the x, y, and z coordinates of a double precision 3d point
05:55 PM nuxil: :)
05:55 PM polygon: () are needed in macro to allow expression as parameter btw
05:55 PM polygon: otherwise it will probably become a mess sometime
05:56 PM polygon: macro is a text replacement tool
05:56 PM nuxil: oki. thx for info :)
05:56 PM polygon: it is like you typed everything it outputs
05:57 PM nuxil: i like macros. but not so good at writing them. esp when it comes to arguments tolkens etc.
05:57 PM polygon: it just does not make a typo and you don't have to write things multiple times
05:58 PM nuxil: macros is like the dark corner of C where all the black magic happens :p
05:58 PM polygon: i think an advanced type of macro could replace C+ so no C++ is needed, ever
05:59 PM polygon: first versions of C++ created C code btw
05:59 PM nuxil: i know little to 0 about C++m but dosent it use this template thingy instead?
06:00 PM polygon: i see nothing against creating "templotes" in C
06:00 PM polygon: "templates"
06:01 PM polygon: you can do whatever in C, even inline ASM
06:01 PM nuxil: inline asm is a gcc thiny iirc
06:01 PM polygon: ok that is not portable
06:02 PM nuxil: when was last update to C ?
06:02 PM nuxil: as in the C standards
06:02 PM polygon: tell you an interesting stuff, there is/was inline asm in turbo pascal too, and sphinx C-- was an assembler that had C capability
06:03 PM nuxil: C11 is last version?
06:04 PM polygon: http://c--sphinx.narod.ru/indexe.htm - i think this died in 2001 approx though
06:04 PM polygon: C is here to stay
06:05 PM nuxil: i dont get why auto is still in C. they removed/changed so many other things in the past.
06:06 PM polygon: i don't follow the "trend" of gcc
06:07 PM polygon: i might prefer to start using M4 and TinyCC/LLVM
06:08 PM nuxil: why?
06:09 PM polygon: author of TinyCC is a cool dude and is proof that intelligent people have trouble using bloated dumb shit like libx264
06:09 PM polygon: nuxil: because gcc is a dead end
06:11 PM nuxil: a dead end?
06:11 PM Emil: noo
06:12 PM nuxil: polygon, why do you belive its a dead end ?
06:13 PM polygon: well t is perpetually developed, in multiple timelines (lol) and there never is a stable bugfree version, there never will be, even if it were to be stable, they would just introducea new dumb useless feature that breaks at random
06:13 PM polygon: it is also huge, and nobody know what it really does
06:14 PM polygon: mathematicians can write an approximation of what it does - mostly- but that's all
06:14 PM polygon: same for x-chat
06:51 PM nuxil: xchat is obsolete
06:51 PM nuxil: its hexchat ftw now
06:51 PM polygon: ya heard of it
06:52 PM polygon: lost time i complained on xchah chan i got banned ;>>
06:52 PM polygon: last time i complained on x-chat chan i got banned ;>>
06:53 PM nuxil: lol
07:48 PM polprog: cant sleep
07:48 PM polprog: xchat was my very first irc client
07:51 PM Casper: mirc was my first
07:52 PM Casper: was like mirc 4.x...
07:53 PM polprog: i would probably install mirc now that i have irssiproxy. i just need to enable it
08:07 PM polygon: hy sup polprog
08:07 PM polprog: cant sleep
08:07 PM nuxil: drink more coffee :D
08:07 PM polprog: maybe its cos i have a laptop on my laps :P
08:07 PM polprog: i tried to sleep but i woke up and kept experimenting with rs 485 :P
08:08 PM polprog: ill make a slave device tomorrow on an avr or one on stm32 when they come
08:08 PM polprog: now i got blue pill chip's datasheet open trying to decrypt a led blinky example from the net
08:09 PM nuxil: bluepill?
08:09 PM nuxil: a nucleo thingy ?
08:09 PM polprog: http://polprog.net/papiery/stm32/Bluepillpinout.gif
08:10 PM nuxil: ok
08:10 PM polprog: "the $5 ebay stm 32 board"
08:16 PM polprog: great the datasheet part named "gpios" is like 5 lines long
08:16 PM polprog: apparently register summary and description is secret knowledge
08:18 PM polprog: ok found a "reference manual" 1k pages, looks promising
08:18 PM polprog: this is it
08:29 PM polprog: so
08:30 PM polprog: i found GPIOC_CRH register, i found that every pin can have some modes
08:30 PM polprog: GPIOC_CRH = (GPIO_CNF_OUTPUT_PUSHPULL << (((13 - 8) * 4) + 2));
08:30 PM polprog: now im trying to crack that magic number
08:30 PM polprog: or am i
08:31 PM nuxil: GPIOC_CRH = (GPIO_CNF_OUTPUT_PUSHPULL << (((13 - 8) * 4) + 2));
08:32 PM nuxil: why ?
08:32 PM nuxil: and not just GPIOC_CRH = (GPIO_CNF_OUTPUT_PUSHPULL << 12 );
08:32 PM polprog: i think i can see why this insane number juggling has its place
08:34 PM polprog: 13 since pin 13. -8 since CRH register "starts" with gpio8. *4 since every "field" (== pair of MODE and CNF (what's this acronym)) is 4 bits long. finally +2 since CNF register starts at bit two
08:34 PM polprog: which compared to DDRA |= (1<<2) is just _unholy_
08:35 PM polprog: what was in their minds when they designed opencm3
08:35 PM nuxil: jeez
08:35 PM polygon: TCCR1A &= ~((1<<COM1A1)|(1<<COM1A0)|(1<<COM1B1)|(1<<COM1B0)); // timer1: turn off compare output modes
08:35 PM polygon: polprog: you can do this kind of magic
08:35 PM polprog: i know
08:35 PM polprog: but this is just a simple bitmask
08:36 PM polygon: there are bit indexes defined by default for your part
08:36 PM polprog: that is... i dont even know how to call that.
08:37 PM polprog: since bits [23:22] are CNF13, whatever that means, then GPIO_CNF_OUTPUT_PUSHPULL must be 0b10
08:37 PM polprog: thats just crazy
08:37 PM polprog: there must be a simpler way with macros to do that
08:37 PM polygon: MCUCR &= ~(1<<PUD); // global enable weak pullups DDRD |= (1<<SSR_led)|(1<<red_led)|(1<<green_led)|(1<<blue_led); // Set RGB pins port D as output DDRD &= ~((1<<PORTD6)|(1<<PORTD7)); // Set inputs as inputs PORTD |= ((1<<PORTD6)|(1<<PORTD7)); // Set inputs weak pullup
08:38 PM polprog: ive been doing c like that on avrs for the last two years
08:39 PM polygon: DDRB = 0x00; // PORTB all input ... PORTB = 0xff; // ... with pullups.
08:39 PM polygon: polprog: i dont see how you want to simplify a bitfiesd generator
08:40 PM polygon: bitfield
08:40 PM polygon: bitmask is generated and it will become a byte.
08:40 PM polprog: say like GPIOC_CRH |= GPIO_CNF_OUTPUT_PUSHPULL << GPIO13BASE; where GPIO13BASE is that magin number (20, which is where MODE13 and CNF13 pair starts in CRH register)
08:41 PM polprog: http://polprog.net/papiery/stm32/stm32f103xx-reference-manual.pdf page 171
08:42 PM polprog: define some more macros, (opencm3 is just macros of macros) and fix that crap
08:43 PM polprog: i will make myself a small header which defines all the GPIOxxMODE and GPIOxxCNF so i can avoid things like that triple parentheses (of which one is redundant)
08:43 PM polygon: so where do you see improvement opportunities?
08:44 PM polygon: Do you have a better method ?
08:44 PM polprog: simply put the problem is that you have to do that number juggling (get pin no, subtract 8 if its the high reg, multiply by four, add two for offset)
08:45 PM polprog: i just said define GPIOxxMODE and GPIOxxCNF macros that for gpio13 in CRH would be 20 and 22 respectively
08:45 PM polprog: or use existing field names from that register, MODExx and CNFxx
08:46 PM polprog: thats my solution
08:46 PM polprog: #endrant //stm32
08:46 PM polygon: #define f13(_inp_) ((((_inp_)-8)*4)+2)
08:47 PM polygon: something like this?
08:47 PM polprog: oh, very ncie
08:47 PM polprog: nice*
08:47 PM polprog: i need to read on preprocessor macros.
08:47 PM polygon: yeah well if you need to use this many times you sould
08:47 PM polprog: this is a macro that sets a gpio pin mode, its used all over the code :P
08:48 PM polygon: so no typos
08:48 PM polygon: hm ;/
08:48 PM polprog: an ideal one would select GPIOx_CRH and GPIOx_CRL register basing on GPIO pin number (0-7 = CRL, 8-15 = CRH)
08:48 PM polprog: i think im gonna open an issue on their github. see what happens
08:50 PM polygon: that is 8 bit gpio
08:50 PM polprog: what do you mean
08:50 PM polygon: 8 ports on 1 control
08:50 PM polprog: yeah, 8 pins, 4 bits each = 32 bits, whole registe
08:50 PM polprog: r
08:50 PM polygon: or is it
08:51 PM polygon: so what is your goal?
08:51 PM polprog: open up the pdf, see the register structure
08:53 PM polprog: get rid of the magic numbers
08:55 PM polprog: setting CNF13 bit field in GPIOX_CRH: GPIOC_CRH |= GPIO_CNF_OUTPUT_PUSHPULL << CNF13; CNF13 is 22, like the bit number in the register
08:55 PM polprog: that maths simplify to 22 (((13 - 8)*4 ) +2)
08:56 PM polprog: is this clear :P?
08:58 PM polygon: have you seen an example code? are you sure you are doing it right?
08:59 PM polygon: it doesn't matter if the math is simplified if it can be simply preprocessed
09:00 PM polygon: gcc calculated my 3x3 matrix transformations at compile time and compiled in the results :)
09:00 PM polprog: ive seen https://github.com/satoshinm/pill_blink/blob/master/opencm-registers/pill_blink.c
09:00 PM polprog: where do you think i pulled that line from
09:01 PM polygon: hm yea i agree that looks nasty
09:01 PM polygon: GPIOC_CRH = (GPIO_CNF_OUTPUT_PUSHPULL << (((13 - 8) * 4) + 2)); GPIOC_CRH |= (GPIO_MODE_OUTPUT_2_MHZ << ((13 - 8) * 4));
09:01 PM nuxil: it looks awefull
09:01 PM polygon: would not want this in my code
09:02 PM polprog: i found a lot of blinky examples but that one was most similar to what i know from avrs (macro definitions for bit fields and register)
09:02 PM polprog: but there is not a single comment in any of those and that sucks
09:03 PM polprog: if you llok into bare-metal directory there you will see him doing the same thing but on raw adresses with typecasts (hence why i had to learn about typecasting in C on this channel ;) )
09:06 PM polygon: well *4 = <<2 btw
09:12 PM Tom_itx is now known as Tom_L
09:33 PM polygon: polprog: 1st hack: https://gist.github.com/anonymous/7439249d5c915ffd81e8cd8f56e232b0
09:35 PM polygon: again https://gist.github.com/anonymous/d399269c77fa9000ac395fc696a6746d
09:36 PM polygon: ;/ ok finally i can paste https://gist.github.com/anonymous/7a87bf8e4f02577e73054b0cd01115cc
09:37 PM polygon: something like this would be ok "setp_CRH(GPIO_CNF_OUTPUT_PUSHPULL, GPIO_MODE_OUTPUT_2_MHZ, 13);"
09:45 PM rue_: (((13 - 8) * 4) + 2))... wtf?
09:45 PM rue_: is 22
09:45 PM polygon: 13 is the "parameter" lol
09:47 PM rue_: maybe adding libocm3 ?
09:47 PM rue_: would make for readable?
09:47 PM rue_: you are, I'm waking up
09:47 PM rue_: wtf are you doing?
09:48 PM rue_: omg your flashing an led
09:48 PM rue_: k
09:48 PM rue_: you looked at my examples too, right?
09:49 PM rue_: http://ruemohr.org/~ircjunk/programming/c/stm32/blink2/main.c
09:49 PM rue_: http://ruemohr.org/~ircjunk/programming/c/stm32/stm32.tgz
09:50 PM polygon: rue_: much better ;)
09:52 PM polygon: rue_: may i interest you in #define F_CPU 40e6 ?
09:53 PM rue_: no, cause I'm running at 72, or 48...
09:53 PM rue_: 72Mhz iirc
09:55 PM polygon: 72 is good
09:55 PM rue_: I'm more carefull iirc in the other examples
09:55 PM rue_: and they have the makefiles
09:55 PM rue_: so you just make; make install
09:56 PM polygon: make install does openocd? ;)
09:56 PM rue_: it was painfull, lets recall
09:57 PM rue_: oh no, I pressed tab on a broken nfs link, my computer will be tied up for a while
09:57 PM polygon: alt tty killall -KILL
09:59 PM polygon: what do you suggest as avr/arm programming/compiling toolchain directory prefix structure/tree?
10:00 PM polygon: i was thinking about /arm/gcc/........... && /avr/gcc/...........
10:01 PM polygon: and either have separate prefix for every dependency/tool, or a common one
10:01 PM polygon: separate would allow simply deleting and replacing one by one
10:18 PM shifttymike is now known as Guest28601
10:19 PM _ami_: polygon, why to program via bare registers when you have a nice wrapper lib like libocm3?
10:19 PM _ami_: i don't see a point.
10:20 PM _ami_: i wrote a simple proj template for those blue pills: https://github.com/amitesh-singh/libopencm3-proj-template
10:32 PM polygon: _ami_: i was replying to polprog
10:32 PM polygon: _ami_: i see there is a cool projct there, https://github.com/libopencm3/libopencm3-examples/blob/master/examples/stm32/f3/stm32f3-discovery/button/button.c
10:33 PM polygon: this looks clean
10:33 PM nuxil: meh.
10:33 PM _ami_: polygon, thats f3 example and it won't work on your "f1" blue pill.
10:34 PM polygon: i dont have f1 ;)
10:34 PM nuxil: avr-gcc did it right :p this stm32 stuff looks like mess :p
10:34 PM _ami_: also the gpio setup functions for f1 and other stm32fxx family in opencm3 is different.
10:34 PM _ami_: nuxil, its just more complex.
10:34 PM _ami_: avrs are easier to program.
10:34 PM _ami_: and probably learn faster than these stm32s
10:35 PM nuxil: avr easyest of them all
10:35 PM polygon: you dont have to use dma if you dont want to
10:35 PM nuxil: but yea. sure its more complex
10:36 PM _ami_: learning stm32 can be a ticket to come out of avr egg shell ;)
10:37 PM nuxil: its warm and cosy in this avr egg :p
10:37 PM _ami_: :)
10:41 PM _ami_: back to thinking mode of making a diy bench power supply. Guys, where to buy those nice enclosure for this?
10:41 PM nuxil: ebay
10:41 PM _ami_: its shame that i don't have a bench supply yet. :/
10:41 PM nuxil: :D
10:41 PM _ami_: oh, they sell those.
10:41 PM * _ami_ searches
10:42 PM nuxil: what do you need ? plastic or aliminium ?
10:43 PM nuxil: aliminium is a bit expencive.
10:43 PM _ami_: i think plastic would be fine. easier to drill.
10:43 PM nuxil: there are these ones.
10:43 PM nuxil: https://www.ebay.com/itm/Waterproof-Plastic-Electronic-Enclosure-Project-Box-Black-200x175x70mm/362180123152?_trkparms=aid%3D555018%26algo%3DPL.SIM%26ao%3D2%26asc%3D47301%26meid%3De0571353b61f46ea8ab50feac526050f%26pid%3D100005%26rk%3D2%26rkt%3D6%26mehot%3Dag%26sd%3D331210803660&_trksid=p2047675.c100005.m1851
10:44 PM nuxil: i have one of thouse on the way
10:44 PM _ami_: neat!
10:44 PM _ami_: thanks
10:44 PM nuxil: or https://www.ebay.com/itm/SV1063-10-Full-Aluminum-Project-Enclosure-Instrument-Case-Electronic-Box/252311972515?_trkparms=aid%3D888007%26algo%3DDISC.MBE%26ao%3D1%26asc%3D20131227121020%26meid%3Db454198337cf4dc39266d1d48a0df45e%26pid%3D100009%26rk%3D1%26rkt%3D1%26sd%3D362180123152&_trksid=p2047675.c100009.m1982
10:44 PM nuxil: if you want more expensive stuff
10:45 PM nuxil: just get yourself one of these: https://www.ebay.com/itm/Buck-boost-converter-Constant-Voltage-current-Programmable-digital-control-Power/222416931643?ssPageName=STRK%3AMEBIDX%3AIT&_trksid=p2057872.m2749.l2649
10:45 PM nuxil: for your diy power supply
10:46 PM nuxil: if thave great efficiency 95%+
10:46 PM _ami_: yeah, i saw those.. good reviews about this product.
10:47 PM nuxil: look at david jones doing review on them.
10:47 PM nuxil: eevblog
10:47 PM _ami_: yes, i saw that before. will check again. thanks for reminding.
10:48 PM _ami_: nuxil, is it too difficult make one using step down converter and a ina219/avr current/voltage measurement?
10:49 PM nuxil: hmm interesting. i2c chip
10:50 PM nuxil: well should not be too difficult.
10:50 PM _ami_: 0 to 25v is what i need.
10:50 PM _ami_: i only have either step up or step down ones :/ not the buck/boost converter.
10:50 PM _ami_: wanted current control feature :(
10:51 PM _ami_: probably buy one of those buck/boost converter with CC/VC
10:51 PM nuxil: yea. you need a shunt resistor for that.
10:51 PM _ami_: yes, i don't have shunt R as well. :( whenever i really want to make something, i don't have those. :/
10:51 PM _ami_: bummer!
10:52 PM nuxil: lol. i know right :p
10:52 PM nuxil: pwm ?
10:52 PM nuxil: pwm from your mico a mosfet
10:53 PM nuxil: then just buy one of thouse cheep Amp meter controls. :p
10:54 PM _ami_: yeah, thats better :)
10:54 PM _ami_: will need FAN too
10:59 PM rue_: polygon, did you download that tar and check yet?
10:59 PM rue_: http://ruemohr.org/~ircjunk/programming/c/stm32/stm32.tgz
10:59 PM rue_: that tar
10:59 PM rue_: which tar?
10:59 PM rue_: http://ruemohr.org/~ircjunk/programming/c/stm32/stm32.tgz
10:59 PM rue_: that tar
11:02 PM polygon: rue_: havent checked yet :)
11:02 PM nuxil: hmm 3 days until bit of fluke 287 ends. bid is at $215, should i bid or wait :p hmm hmm :p
11:02 PM polygon: rue_: so how long since have been on arm?
11:02 PM polygon: *you
11:03 PM rue_: install: program.elf
11:03 PM rue_: openocd -f $(OPENOCD_SCRIPTS_DIR)/inter...
11:03 PM rue_: so yes, make install uses openocd
11:03 PM nuxil: someone should make stmdude :p
11:03 PM rue_: my last work was on Dec 12
11:04 PM polygon: rue_: when did you start arm?
11:04 PM rue_: about May 28
11:04 PM polygon: will you progress to fpga? ;>
11:04 PM rue_: maybe in a few years, maybe GPU
11:05 PM polygon: doubt that gpu has anything to do with this ;)
11:05 PM polygon: FPGA can be a CPLD
11:05 PM polygon: and it is reconfigurable Logic Array
11:05 PM rue_: yea
11:06 PM polygon: we noly need asynchronous logic building blocks and it will beome limitless
11:06 PM polygon: c
11:07 PM rue_: sure
11:07 PM polygon: only downside is the closed nature of the configurator multi-gigabyte bloat
11:07 PM _ami_: i think this year gonna be a FPGA year in makers community.
11:08 PM rue_: their still pretty pricey
11:08 PM polygon: CPLD costs as much as an atmega
11:08 PM rue_: you gonna build the arduino library for the winning fpga?
11:09 PM polygon: https://www.xilinx.com/products/silicon-devices/cpld/coolrunner-ii.html
11:09 PM polygon: Ultra-low power (28.8µW)
11:09 PM polygon: yea
11:17 PM polygon: https://www.xilinx.com/products/silicon-devices/fpga/spartan-7.html
11:17 PM polygon: hmm, softcore pc sounds awesome :>
11:18 PM polygon: but it needs to be AMULET 2+
11:40 PM polygon: rue_: cool examples, looks clean, but what is that ~270kB elf file in the directories?
11:53 PM rue_: prolly the one that clean didn't get
11:54 PM rue_: that makefile took me a LOT of pain to make, USE IT.
11:58 PM polygon: rue_: i mean what are they? it is a microcontroller, it has less than 1MB flash
11:58 PM polygon: probably 256k or less
11:58 PM polygon: and machine code is nat that large