#avr | Logs for 2015-03-28

Back
[03:42:26] <malinus> Casper: if you have 1 wire, you can just do manchester.
[03:42:53] <malinus> Casper: no reason to make your own encoding
[04:34:17] <Elec_A> Hello, I am programming an I2C Interface, but i don't know how to know something is on the bus in the Slave ?
[04:34:49] <LeoNerd> ?
[04:34:57] <Elec_A> Master writes data on bus, but i don't know how to read it
[04:35:42] <LeoNerd> What sort of device? Are you using the hardware I2C module? USI? Bitbanging?
[04:36:06] <Elec_A> I am using hardware I2C module.
[04:36:40] <LeoNerd> So, you'll get an interrupt, then you can read the registers
[04:37:29] <Elec_A> SCL will make an interrupt ?
[04:39:07] <Elec_A> LeoNerd: Thank you. I got it :)
[06:47:11] <Fleck> any HD44780 guru here? http://hackaday.com/2014/02/27/fail-of-the-week-reset-issues-with-595-and-hd44780/ << I have similar problem in 4-bit mode, and the only reasonable comment I can think of is this one: http://hackaday.com/2014/02/27/fail-of-the-week-reset-issues-with-595-and-hd44780/#comment-1227889
[06:48:24] <Fleck> as if I reset MCU, LCD stays in 4bit mode and waits for lower or upper bits, so I can only guess... if I understand correctly
[06:51:30] <specing> no issues whatsoever on 16x2
[06:51:40] <specing> using my own 4-bit lib
[06:51:52] <Fleck> share! :)
[06:53:39] <Fleck> would like to see how do you init... and do you reset LCD also on MCU reset?
[06:53:48] <LeoNerd> Surely, you set the D4-D7 bits into the "switch into 4bit mode now please" then pulse EN twice..?
[06:54:11] <LeoNerd> If it was originally in 4-bit mode, it will swich... to 4bit mode. I.e. no-op. If it was in 8bit mode then it's now in fourbit.
[06:55:21] <specing> https://gist.github.com/specing/ded784fd030ec3540ed3
[06:57:05] <Fleck> thanks specing
[07:03:03] <specing> probably the smallest hd44780 lib around. Iirc 44 bytes
[07:05:56] <Fleck> and it works OK if you reset MCU in the middle of data transfer specing?
[07:06:00] <Fleck> every time?
[07:06:53] <specing> I don't know
[07:07:01] <Fleck> :/
[07:07:10] <specing> it has been atleast 3 years since I've touched a hd44780
[07:07:12] <specing> :(
[07:07:26] <LeoNerd> Switch it to 8bit mode then back to 4bit mode
[07:10:29] <Fleck> LeoNerd: ok, let me try
[07:10:43] <Jeroi2> hello
[07:10:48] <Jeroi2> #define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_output_PGM + (P))) )
[07:10:59] <Jeroi2> this is found in Arduino core arduino.h
[07:11:44] <Fleck> wrong chan, don't mention that name here, you will die! :d
[07:11:50] <LeoNerd> Hah
[07:12:11] <LeoNerd> I dunno... "Arduino" as the name of a board form-factor is fine... even as a bootloader sometimes
[07:12:50] <specing> noobduino
[07:13:16] <twnqx> still i didn't see any question
[07:13:24] <specing> neither did I
[07:13:34] <specing> I think we shared it
[07:13:37] <twnqx> and so far this is not arduino specific
[07:13:37] <specing> scared*
[07:14:05] <specing> yes so far a perfectly nice and volatile uint8_t
[07:14:29] <twnqx> except it apparently uses a program-space lookup table to do something with ports, which is ugly.
[07:15:52] <Fleck> [13:51:00] <Jeroi2> this looks like it return uint8_T pointer
[07:15:52] <Fleck> [13:51:30] <Jeroi2> how come it returns uint8_t instead
[07:17:15] <Jeroi2> yes that is the issue
[07:17:37] <Jeroi2> I would want to fetch address of the port
[07:17:53] <Jeroi2> for direct port writes
[07:18:14] <Jeroi2> to gain speed for my project
[07:18:35] <twnqx> if you write pure in C you don't want to do that, but that's a different story
[07:19:48] <Jeroi2> I know there is PORTC and DDR and PIN ints where you can just save byte and it affects ports directly
[07:20:02] <twnqx> exactly
[07:20:03] <Jeroi2> but in my case, I need to convert user selectable pin to port
[07:20:36] <Jeroi2> thus need method in constructor to look in which port the pin is located
[07:20:51] <twnqx> pgm_read_word returns indeed a uint8_t
[07:21:28] <twnqx> i suppose the idea with (volatile uint8_t *) is that you can directly assign a value to the port
[07:21:44] <twnqx> actually
[07:22:16] <twnqx> portOutputRegister(P) will be directly a pointer to the IO port
[07:23:05] <twnqx> i don't think it will be uint8_t that's returned
[07:23:19] <twnqx> what gets you to the conclusion that it does, Jeroi2?
[07:24:00] <Jeroi2> wait a bit
[07:24:54] <Jeroi2> currently the input is like this:
[07:24:55] <Jeroi2> *portOutputRegister(csport) &= ~csmask;
[07:25:29] <Jeroi2> uint_8 csport = portOutputRegister(A4);
[07:26:24] <twnqx> that would work, but might yield a compiler warning
[07:26:32] <Jeroi2> Yeah
[07:26:56] <twnqx> well no, it wouldn't
[07:27:04] <Jeroi2> My questions how can I return a pointer to the portOutputRegister
[07:27:12] <twnqx> you can't
[07:27:17] <twnqx> you can't have pointers to rom
[07:27:28] <Jeroi2> so I could do *csport |= mask;
[07:27:39] <Jeroi2> I mean address
[07:27:45] <twnqx> well, volatile uint8_t * csport = portOutputRegister(A4);
[07:27:56] <specing> Jeroi2: why do you have these problems
[07:28:04] <twnqx> *csport &= ~csmask; *csport |= csmask;
[07:28:10] <specing> #define my_peripheral port PORTB
[07:28:20] <specing> and there you go, user configurable ports
[07:29:35] <Jeroi2> twnqx ok I try this
[07:30:05] <twnqx> but specing is right, his way of defining things will be much faster, though i don't agree with the details :p
[07:30:16] <specing> ofcourse it will be much faster
[07:30:28] <specing> accessing an I/O port via immediate is single cycle
[07:30:41] <twnqx> it's suboptimal, though
[07:30:43] <specing> acessing it via pointer first requires loading the address
[07:30:50] <specing> which is 2 cycles
[07:31:23] <specing> and then accessing via pointer which is 1 cycle
[07:32:06] <specing> And tell me what is easier, changing hardware to be on a different port or changing one #define?
[07:32:10] <twnqx> https://bpaste.net/show/1c2ffc2f6035
[07:32:22] <twnqx> this is what i usually do (first part in a separate header file)
[07:33:34] <twnqx> allows me to stay fully symbolic and confgurable without losing any performance
[07:35:27] <Jeroi2> twnqx
[07:35:30] <Jeroi2> thank you so much
[07:35:51] <Jeroi2> this saves whole switch case need for my current letter script
[07:36:10] <Jeroi2> I can just with one line instead allocate correct port for output
[07:39:04] <Jeroi2> fuck this is creat
[07:39:10] * specing facepalms
[07:39:33] <Jeroi2> I can overwhoul my current port manipulation with your code
[07:39:48] <specing> or you know
[07:39:53] <specing> you could just use C++ templates
[07:39:55] * Lambda_Aurigae hopes Jeroi2 does'nt speak English natively.
[07:40:11] <Lambda_Aurigae> doesn't
[07:40:18] <Lambda_Aurigae> dang it's too early.
[07:40:20] <Jeroi2> I am not native english
[07:42:18] * Jeroi2 thinks no one should think anybody as native eglish speaking person on internet
[07:42:31] <twnqx> always glad to help
[07:44:58] <Jeroi2> thank you so much
[07:46:19] <twnqx> reminds me i wanted to integrate some proof-of-concept that arose from a discussion here into that header file
[07:47:49] <twnqx> https://bpaste.net/show/7d26b824478b the superbly evil version with variable number of arguments for the mask :P
[07:48:15] <Jeroi2> twnqx one question
[07:48:27] <Jeroi2> the mask is doing shift always?
[07:48:39] <Jeroi2> so it slows the speed
[07:48:43] <twnqx> no
[07:48:53] <twnqx> it's calculated at compile time as it's a define
[07:49:06] <twnqx> unless you throw variables in there
[07:49:38] <twnqx> in which case yes, it will caluclate every time, and you should store the shifted mask in a variable
[07:49:55] <Jeroi2> yes
[07:50:02] <Jeroi2> this is what I was thinking
[07:50:21] <Jeroi2> I should use this to store the mask to variable
[07:50:27] <twnqx> the first part won't work with runtime variables though
[07:50:32] <Jeroi2> so the output doas not shift always
[07:50:33] <twnqx> the PORTxxx
[07:50:57] <Jeroi2> yes
[07:50:57] <twnqx> it's all meant for compile time fixation, like you posted
[07:51:31] <Jeroi2> thats not problem
[07:51:40] <Jeroi2> well it is
[07:51:55] <Jeroi2> because user can input in fcuntion pin's
[07:52:15] <Jeroi2> to switch pins on the fly
[07:52:28] <twnqx> but not the port? then yes, store the mask
[07:53:13] <Jeroi2> my idea is to be able to switch output port function
[07:53:21] <Jeroi2> so code can select another display
[07:53:26] <Jeroi2> till example
[07:53:51] <Jeroi2> to be able to controll 2 displays
[07:53:57] <Jeroi2> with port manipulation
[07:54:00] <Jeroi2> and so ne
[07:54:13] <Jeroi2> on
[07:54:51] <Jeroi2> So your code is cood when there is not port switcher function
[07:54:54] <Jeroi2> good
[07:55:39] <Jeroi2> this is my orginal issue
[07:55:48] <Jeroi2> the issue currently is not switcher
[07:56:12] <Jeroi2> I can store my port with siwtch case statement and the output bytes directly to that port
[07:56:23] <Jeroi2> the control bits are the issue
[07:56:41] <Jeroi2> since user can input what ever bits to the controls
[07:57:30] <Jeroi2> so I need method in constructor to store port't registers what users have given in with pins
[07:58:30] <Jeroi2> to be able to gain speed when doing writes
[07:59:04] <Jeroi2> I have already gain quite much with those portOutputRegister masks
[07:59:46] <Jeroi2> but till example pinmode port should be converted to port manipulation to gain speed there
[08:12:28] <LeoNerd> Does anyone have a good suggestion for an abort() implemntation on an ATtiny?
[08:12:45] <LeoNerd> I want to put the IO pins into some sort of non-damaging but clearly "this is an error" state, and then spinlock the chip
[08:21:13] <malinus> I still hate how cumbersome using interrupts is, when doing OOP on avr in c++ :V.
[08:21:43] <LeoNerd> Ah well.. don't do OO ;)
[08:38:19] <vsync_> srs, who the fuck needs c++ on avr
[08:38:35] <vsync_> because python and nodejs are so much better for it
[08:38:46] <vsync_> and ruby on rails
[08:38:54] <vsync_> then u just need mongodb
[08:41:53] <specing> templates are cool
[08:48:40] <Casper> malinus: manchester look complicated, specially with interrupt running...
[09:27:18] <uskerine> For getting an idea on time consumption of a routine, it is relatively easy to set up an output pin and monitor it with a logic analyzer
[09:27:38] <uskerine> it also helps to debug FSMs as you can see when the state change routine is activated
[09:28:22] <uskerine> so you set the pin at the beginning of the routine and clear it at the end
[09:31:06] <specing> count cycles?
[09:31:15] <specing> ... in the listing file
[09:33:02] <uskerine> I don't know hwere to find the list file in Atmel Studio -if someone knows, I am listening-. Additionally being able to look at the logic analyzer screen and watching when two or three routines are executed might be a good debug way for interrupt-driven software (I was debugging a full duplex software UART, where you have both TX and RX interrupt sources -two timers and one external pin-)
[09:37:57] <specing> avr-g++ -std=c++11 -mmcu=$MCU -o $out/$name.s $src $opts -S
[09:38:40] <specing> I neved used atmel studio and I think when they switched to visual studio the amount of people using it in this channel dramatically plumetted
[09:39:11] <uskerine> I see
[09:39:31] <uskerine> Can you safely write this for ATmega328P??? #define BUFFER_SIZE 32 static char RX_BUFFER[BUFFER_SIZE];
[09:39:56] <uskerine> I mean defining a 32 bytes array? Would gcc allocate it properly?
[09:40:57] <uskerine> I am asking because in other architectures you have to switch compilation model to large to ensure external RAM of the uC is used
[09:42:18] <specing> why the three ?
[09:47:41] <uskerine> ???
[09:49:16] <EI24> Hi, the assembler im using avra, cant seems to recognize binary prefix(01001101b). Maybe that is the wrong prefix. Are there some other way to write in binary?
[09:49:59] <EI24> It seems much simpler to write to control registers in binary, rather than in hex
[09:50:01] <EI24> or decimal
[09:51:15] <Lambda_Aurigae> 0b00011010
[10:01:46] <EI24> Lambda_Aurigae: Thanks!
[10:01:53] <Lambda_Aurigae> welcome.
[10:19:20] <antto> specing because it's more dramatic with three
[10:28:27] <specing> drama
[10:39:40] <Tekkkz> Hey LeoNerd, tryed to use m32u4 adafruit breakout for cdc serial communication with pc via LUFA - didnt got it, here an error-there an issue-and that's on the demo by lufa...please take yours and help find out how to communicate pls
[10:40:35] <LeoNerd> Yes I'll get round to it. But this weekend I'm much busy making ATtiny + nRF24L01 radio boards
[10:40:49] <Tekkkz> okay, so maybe next week? :D
[10:40:53] <LeoNerd> If you want it any time soon I still suggest finding other people to help
[10:41:16] <Tekkkz> ofc, i just need some more intelligent guys who can help me :D
[10:55:38] <malinus> vsync_: lol'd
[10:56:33] <malinus> vsync_: your slippery slope fallacy is strong :D
[10:59:22] <malinus> Casper: nah manchester is pretty simple. The overhead won't be much bigger than comparing time (in your on/off time encoding scheme).
[12:09:12] <vsync_> malinus: :)
[12:09:22] <vsync_> i know, right
[12:18:08] <Tekkkz> https://www.adafruit.com/images/970x728/296-00.jpg
[12:18:15] <Tekkkz> look at the isp connector
[12:18:26] <Tekkkz> the right column
[12:18:35] <Tekkkz> under the 3rd there is something
[12:18:43] <Tekkkz> a blank piece of "iron"
[12:18:53] <Tekkkz> with something like gray/green
[12:19:01] <Tekkkz> what is it, whihch function does it have
[12:19:05] <vsync_> "copper"
[12:19:08] <Tekkkz> i see such things often on pcbs
[12:19:12] <Tekkkz> copper yes
[12:19:47] <vsync_> looks like a large via for ground
[12:19:58] <Tekkkz> hm
[12:20:03] <Tekkkz> its two times on this pcb
[12:20:06] <Tekkkz> but i often see it
[12:20:11] <Tekkkz> what is the grey around it
[12:20:18] <Tekkkz> where no solderstop i?
[12:20:20] <Tekkkz> *is
[12:20:42] <Tekkkz> is it just the blank pcb?
[12:20:50] <Tekkkz> and for what are such things on pcb's?
[12:21:15] <vsync_> tje annular ring?
[12:21:16] <vsync_> the
[12:21:36] <Tekkkz> annular ring? whats that?
[12:22:08] <vsync_> jesus.
[12:22:35] <vsync_> http://lmgtfy.com/?q=annular+ring+pcb
[12:22:44] <Tekkkz> i already googled my self
[12:23:36] <Tekkkz> ahh okay
[12:23:45] <Tekkkz> and for what is this ground big via?
[12:24:22] <vsync_> eh
[12:25:24] <vsync_> actually no, sorry my eyes deceived
[12:25:35] <vsync_> they are no ground vias.
[12:26:03] <Tekkkz> hm?
[12:26:18] <vsync_> yeah, they aren't
[12:26:23] <Tekkkz> what are they then?
[12:26:26] <vsync_> i don't know. testing?
[12:26:35] <Tekkkz> how? lol
[12:33:17] <antto> that's NSA transmitters
[12:33:22] * antto hides
[12:33:23] <Tekkkz> haha
[13:38:42] <_abc_> Wow there are 4 rues on the channel. *Someone* doesn't miss a peep ;)
[13:53:05] <N1njaneer> _abc_: Better than four 'roos, I suppose. Hopping all about!
[13:55:08] <Casper> malinus: do you have doc about it that is good and all?
[14:36:43] <malinus> Casper: the wiki article explains it pretty well iirc
[15:13:00] <Flipp___> ugh, so close to getteing i2c to work! :)
[15:13:46] <Flipp___> I keep trying to read the WHO_AM_I register but it returns 0 >.<
[16:32:57] <Flipp___> got it, nevermind, I'm just a moron >.<
[16:33:41] <Flipp___> note to self: set TWDR *before* writing TWINT/TWEN D:
[16:46:01] <Casper> malinus: wiki of wikipedia?
[16:46:10] <malinus> pedia
[18:29:14] <uskerine> in serial communication, is first bit transmitted LSB or MSB?
[18:30:38] <uskerine> Another question-> what is wrong with char subscripts for arrays? isn't better in terms of performance for an 8 bit architecture? Warning 1 array subscript has type 'char' [-Wchar-subscripts] 206 2 Serial
[18:33:30] <malinus> uskerine: unsigned should fix your second problem.
[19:56:34] <uskerine> DDRD |= (1<<PD4); // PD4 AS OUTPUT
[19:56:34] <uskerine> DDRD &= ~(1<<PD3); // PD3 AS INPUT
[19:56:43] <uskerine> are those sentences properly specified?
[21:38:55] <aandrew> balls. is there a way to undo a JTAGEN fuse blow on AT90CAN?
[21:43:39] <Casper> aandrew: do you have any other mean to program? like ISP?
[21:45:33] <aandrew> well there's no HVSP protocol for the at90can, and I don't think ISP is there either
[21:47:10] <Casper> hmmm
[21:47:34] <Casper> at90canwhat?
[21:48:13] <aandrew> at90can32
[21:48:29] <Thrashbarg> at90canDo
[21:50:20] <Casper> high fuse contain SPIEN
[21:50:31] <Casper> Enable Serial Program and Data Downloading
[21:51:23] <Casper> if that is still enabled you're golden
[21:51:49] <Casper> page 307 say "The RESET pin accepts 3V or 5V active low logic for standard reset operation, and 12V active high logic for High Voltage Parallel programming."
[22:11:42] <aandrew> hm ok
[22:11:55] <aandrew> let me see if I can program it through that
[22:12:00] <aandrew> thank you Casper
[22:49:36] <Casper> now manchester...
[22:51:24] <Casper> somehow I can't figure out how to do it... grrr
[22:51:33] <Casper> encoding is easy... but decoding is what bug me
[23:00:30] <aandrew> IIRC you can decode manchester with an xor gate and the recovered clock
[23:00:56] <Casper> software only
[23:01:02] <aandrew> ah
[23:04:12] <Casper> and my main issue is... how do I recover clock...
[23:04:26] <Casper> I guess I'll just steal someone's code
[23:04:41] <Casper> and modify it for my own use...
[23:05:02] <Casper> I want to send a 32 bits instead of 8
[23:36:50] <Casper> oh... you decode manchester by the midbit transition, low is high to low, high is low to high.... that make it damn easy to do, now, the hard part: clock recovery
[23:40:31] <Casper> so really, the hard part is the clock recovery
[23:41:27] <Casper> which... may not be that hard... if I use the timer as a timebase... the worst that can happend is a 1 bit length of no transition...