#avr | Logs for 2016-03-04

Back
[05:22:31] <mohsen_> What is a register in the context of serial communication?
[05:36:02] <mohsen_> What is a register in the context of serial communication?
[05:40:34] <mohsen_> Or is it only limited to serial?
[05:40:55] <Snert__> a register is usually 8 bits or storage locations.
[05:41:02] <Snert__> maybe 16 locations .
[05:41:04] <RikusW> a register is general purpose, and used to control many peripherals
[05:41:19] <Snert__> regardless of things like serial or protocol.
[05:41:26] <RikusW> err, more like io port
[05:50:18] <daey> mohsen_: do you mean the buffer register? you can write into it, in one cycle. it then automatically pushs out the data over multiple cycles without interfering with the main cpu
[05:51:42] <mohsen_> No I mean the register in this example: https://www.sparkfun.com/tutorials/240
[05:52:22] <mohsen_> Is it used to tell the sensor what data we need?
[05:52:52] <Lambda_Aurigae> there are general purpose registers that are used by code to hold data.
[05:52:52] <Lambda_Aurigae> and
[05:53:04] <Lambda_Aurigae> there are special function registers that are used to control peripherals.
[05:55:32] <Lambda_Aurigae> in that particular code, those POWER_CTL and DATA_FORMAT are control registers...write only apparently...used to tell the chip how to do things.
[05:55:46] <Lambda_Aurigae> the DATAxx registers are read only to get the data back out of the chip.
[05:57:15] <Lambda_Aurigae> writeRegister() and readRegister() use some spi code to, well, write and read the registers on the chip connected via spi.
[06:00:50] <mohsen_> How is the buffered then?
[06:00:51] <mohsen_> the data*
[06:02:27] <Lambda_Aurigae> on the chip in question.
[06:02:40] <Lambda_Aurigae> I suggest actually reading the datasheet of said chip.
[06:03:30] <Lambda_Aurigae> I've never used that chip or had any need for such so haven't read the datasheet.
[06:08:33] <mohsen_> Whats the disadvantage of AT commands that they don't use it for these chips?
[06:09:09] <Lambda_Aurigae> huh?
[06:09:19] <Lambda_Aurigae> AT commands are used for modems usually.
[06:10:41] <Lambda_Aurigae> also used when you are commanding something via rs232 type text based serial communications.
[06:10:57] <Lambda_Aurigae> that chip uses spi to access its internal registers for commanding it.
[06:14:39] <mohsen_> Have I understand it correctly? that chip has some registers that provide various data, and you ask for a specific register's data through SPI?
[06:15:26] <Lambda_Aurigae> yes
[06:15:32] <Lambda_Aurigae> didn't you actually read the tutorial?
[06:15:36] <Lambda_Aurigae> including the source.
[06:15:52] <Lambda_Aurigae> the same one you posted the link to.
[06:16:06] <Lambda_Aurigae> it's even for ardweeny.
[06:16:24] <mohsen_> I just took a look at the source code
[06:16:42] <Lambda_Aurigae> that's very self explanatory too...there are comments.
[06:16:52] <Lambda_Aurigae> but,,I recommend reading the whole thing,,,AND the datasheet.
[06:19:31] <mohsen_> I've read the registers part in the datasheet actually, wanted to see how it is used in code, so visited that link
[06:33:05] <mohsen_> What does this syntax do: "<<" ? I suppose its only limited to arduino's c++ syntax?
[06:36:22] <Lambda_Aurigae> depends on where and how it is used.
[06:39:00] <mohsen_> Consider in this line "x = ((int)values[1]<<8)|(int)values[0];"
[06:39:06] <Lambda_Aurigae> it is defined as bit shift
[06:39:31] <Lambda_Aurigae> it is also overloaded as a stream assignment or something like that.
[06:40:20] <Lambda_Aurigae> https://en.wikipedia.org/wiki/Bitwise_operation#Bit_shifts
[06:41:20] <Lambda_Aurigae> in that line it is shifting values[1] by 8 bits.
[06:41:42] <mohsen_> Hmmm,
[06:42:01] <mohsen_> Thanks anyway
[06:42:10] <Lambda_Aurigae> hence the (int) cast, making values[1] a 16 bit integer so it can shift the lower 8 bits over to the upper 8 bits.
[06:42:42] <Lambda_Aurigae> it then adds in values[0] as the lower 8 bits and stores that in x
[06:43:43] <Lambda_Aurigae> values0 starts out as yyyyyyyy where yyyyyyyy is your 8bit data...it gets cast to a 16bit integer so it looks like 00000000yyyyyyyy..
[06:43:56] <Lambda_Aurigae> then it gets shifted 8 bits over so it looks like yyyyyyyy00000000
[06:44:15] <Lambda_Aurigae> values1 gets converted to 00000000zzzzzzzz by the (int) cast
[06:44:29] <Lambda_Aurigae> then the two are combined with a logic OR
[06:44:36] <Lambda_Aurigae> giving you yyyyyyyyzzzzzzzz
[06:44:56] <mohsen_> Thanks for your thorough explanation Lambda_Aurigae, I have to something else
[06:45:04] <mohsen_> to do*
[06:45:12] <mohsen_> Because you know
[06:45:20] <mohsen_> I should code in Java
[06:45:25] <Lambda_Aurigae> bah.
[06:46:00] <mohsen_> So I think I should read the datasheet and build a library for it, am I right?
[06:46:09] <Lambda_Aurigae> I code in java, c, c++, assembly on at least 8 processors, cobol, fortran, pascal, perl, and can work my way through just about any modern language out there.
[06:46:18] <Lambda_Aurigae> go for it.
[06:46:50] <Lambda_Aurigae> that's what I usually do for a new chip I'm playing with.
[06:47:13] <Lambda_Aurigae> or go steal a lib from someone else and mod it to my own purposes.
[06:47:32] <Lambda_Aurigae> like my twi interfaced 16x2 character LDC system from 10 years ago.
[06:48:52] <Lambda_Aurigae> I took peter fleury's i2c and lcd libs and combined them with what I knew of the pcf8574 chip to make a combined lib for i2c interface of lcd display...
[06:49:01] <mohsen_> I'd wanted to find a library for it and well, steal it, but there is none, no body codes in Java for using these chips:-\
[06:49:10] <Lambda_Aurigae> I built a dozen lcd/pdf8574 chip displays for hooking to everything I built.
[06:49:33] <Lambda_Aurigae> that's because java is not a low level programming language.
[06:49:44] <mohsen_> Yeah
[06:50:01] <Lambda_Aurigae> it's for making user interfaces, not device drivers
[06:50:30] <Lambda_Aurigae> anybody using java to write device drivers needs to be hanged, shot, beheaded, drawn and quartered, then burned at the stake(just to be certain)
[06:50:49] <Lambda_Aurigae> anybody writing anything in java that they expect to be secure needs to just be exiled from the human race.
[06:50:59] <mohsen_> Whoa, hang on man
[06:51:45] <Lambda_Aurigae> I worked for a company where the ceo thought java was the end-all-be-all programming language.
[06:52:24] <Lambda_Aurigae> it was reverse engineered(even after being obfuscated) by a client and the company I worked for went out of business.
[06:52:35] <mohsen_> Do you agree that we should use a high level language when project is heavy?
[06:52:49] <Lambda_Aurigae> they have their places.
[06:53:20] <Lambda_Aurigae> java is ok for making user interfaces.
[06:53:26] <Lambda_Aurigae> beyond that, I don't see much use for it.
[06:53:34] <mohsen_> Well, what if their place is my project?
[06:53:45] <Lambda_Aurigae> go for it.
[06:53:51] <Caesium> Lambda_Aurigae: Lucene disagrees with you
[06:54:01] <Snert__> it's cross platform, but so often poorly implemented.
[06:54:06] <Caesium> and Elasticsearch etc.
[06:54:09] <Snert__> so I hate java
[06:54:21] <mohsen_> You say using a different language for the backend processes and Java for only the view?
[06:54:24] <Lambda_Aurigae> I also believe that programmers need to learn lower level languages first then move up to the higher level stuff. you learn how the system works much better.
[06:54:39] <Lambda_Aurigae> mohsen_, that's what I would do if I used java.
[06:54:57] <Lambda_Aurigae> I won't voluntarily write anything in java...I just stick with C...but that's mostly a personal preference.
[06:55:14] <Lambda_Aurigae> Caesium, most people disagree with me...I'm a bastard.
[06:56:17] <Lambda_Aurigae> I suppose java would be good for writing crapps for phones.
[06:56:48] <Caesium> yeah, cos phones are known for having the 4GB of memory available that a Java app needs ;)
[06:57:13] <Caesium> Android manages it though, so it must work.
[06:57:14] <Lambda_Aurigae> Caesium, ok..good is not the right word there....
[06:57:22] <Caesium> I've never done Android dev. Done some iOS though, and thats Objective C
[06:57:38] <Lambda_Aurigae> I've played with some android dev and dropped it like a hot potato....
[06:57:59] <Lambda_Aurigae> switched back to a couple of AVRs and a 14 inch touchscreen monitor from the 90s.
[06:58:44] <Lambda_Aurigae> ok..maybe from 2000...it is a flatpanel 14 inch ELO touchscreen with serial port touch interface.
[06:59:49] <mohsen_> Java eats more memory compared to C, but isn't it a good sacrifice for code readablity and safety?
[07:00:01] <Lambda_Aurigae> combined Jartza's octapentaveega display adapter, these DMM chips I got from maxim-ic.com, and an atmega1284p to glue it all together, I got a big display DMM with multiple inputs for doing current and voltage simultaneously.
[07:00:11] <Lambda_Aurigae> java code safe?
[07:00:22] <Lambda_Aurigae> and readable?
[07:00:38] <mohsen_> Lambda_Aurigae: Assuming safety is different from security.
[07:00:58] <Caesium> meh, I don't subscribe to the idea that Java is inherently unsafe. any language can be made unsafe. You can write unsafe Perl quite easily.
[07:00:59] <Lambda_Aurigae> then I have no clue what you mean by safety.
[07:01:03] <Caesium> it's all in the hands of the programmer.
[07:01:07] <mohsen_> Lambda_Aurigae: Do not struggle with me about it not being readable! :D
[07:01:28] <mohsen_> Caesium: Agreed
[07:01:39] <Lambda_Aurigae> I find C just as readable as perl and java and cobol and pascal and fortran.
[07:02:09] <mohsen_> Lambda_Aurigae: Not using pointers and stuff!
[07:02:13] <Lambda_Aurigae> why not?
[07:02:16] <nikomo> I find Perl just as readable as Cyrillic - I can't read it
[07:02:18] <Lambda_Aurigae> I understand pointers just fine.
[07:02:44] <Lambda_Aurigae> but I also find assembly readable and pointers are used in assembly all the time.
[07:03:09] <Lambda_Aurigae> 6502 assembly being the second programming language I learned back in the 80s.
[07:03:16] <Thrashbarg> pointers pointing pointy pointing pointers
[07:03:53] <Lambda_Aurigae> so java just eliminated pointers...takes some of the fun out of the whole project.
[07:04:03] <Thrashbarg> anyone used Forth??
[07:04:15] <Lambda_Aurigae> played with it some years back.
[07:04:23] <Lambda_Aurigae> didn't find a use for it in my arena though.
[07:04:37] <Thrashbarg> yeah it's a bit of a misfit for most things
[07:05:05] <Lambda_Aurigae> another of those, "why use it if I can already do it in C quicker and easier?" things
[07:05:28] <mohsen_> I think for a small project, that you can deal with pointers and make sure your code is safe, C is an efficient language to use. but for huge projects, dealing with pointers is really hard, and coding a huge project in procedural language is not a good idea, using oo would make it even more readable, so for a big project, its better an OO one be used.
[07:05:49] <Lambda_Aurigae> mohsen_, huge projects, like, say, the linux kernel?
[07:06:15] <Lambda_Aurigae> I still don't see how oo makes things more readable,,,but, again, I am an old assembly and C hacker from way back.
[07:06:18] <mohsen_> You know your answer Lambda_Aurigae ;)
[07:07:42] <Lambda_Aurigae> how you handle a large project depends as much on the coder as the code...probably moreso.
[07:08:07] <Lambda_Aurigae> uncommented java or C++ is just as horrible to try to debug as uncommented C or assembly.
[07:08:25] <Lambda_Aurigae> aaaand, time to head for worky...laters.
[07:10:44] <mohsen_> Lambda_Aurigae: Our struggle will never end, I know.. :D. so go for your work and I'd go for lunch.
[07:14:21] <Thrashbarg> mm I don't think OOP helps large projects, but it helps with event driven stuff, like GUI's. Depends on what you're doing.
[07:33:31] <nikomo> I think OOP is fairly silly when you're working on something where you end up with a bazillion singletons
[07:43:40] <Jartza> hallo
[09:41:09] <Chocobo> Hi all, I am trying to debug an xmega64d3 that resets due to wdt. Is there a way to catch this with a debugger? It doesn't look like the wdt has an interrupt vector (WTF?!) so I am having a really tough time inspecting the stack of various tasks.
[09:45:52] <Casper> WDT DOES have an interrupt vector: reset
[09:46:59] <Casper> then there is a register you can check to know what was the reset source, which have flag for atleast reset pin, power up, BOD and WDT
[09:47:05] <Chocobo> I will give that a shot. Thanks
[09:49:11] <Chocobo> As long as the sram is still in a state that I can inspect I should be fine.
[09:49:31] <Chocobo> The code I am working with is a real cluster :/
[09:51:29] <Casper> also, an unhandled interrupt will cause a reset
[10:00:39] <Chocobo> Thanks Casper, this is working well. Now if only avarice could read io mapped registers :/
[10:03:32] <Casper> avarice sound like an ugly illness...
[10:04:40] <Chocobo> It is.
[10:49:31] <h4x0riz3d> does the ftdi usb-serial require drivers on linux too?
[10:57:54] <Jartza> usually no
[10:58:17] <Jartza> mostly they are built in to kernels in usual distros
[12:27:23] <WormFood> [20:26:58] <Lambda_Aurigae> it was reverse engineered(even after being obfuscated) by a client and the company I worked for went out of business. <-- actually, you can RE anything, it's just how much effort you want to put into it.
[17:36:58] <julius> ive got a atmega32 running on 8mhz, by accident i uploaded code that was compiled for 16mhz. now the led blinks faster than once per second
[17:37:07] <julius> i would expect the led blink slower...why is it faster?
[17:38:15] <liwakura> wat
[17:43:53] <inkjetunito> julius: how did you implement the delay?
[17:58:26] <julius> Lambda_Aurigae, turns out that not all of the 4 grounds on the 10pin connector are actually connected...thats why my connection wasnt working
[17:58:34] <julius> _delay_ms(1000)
[18:01:02] <Lambda_Aurigae> julius, guess that depends on your particular programmer..on one of mine they are. on another the extra ones are used to connect to the serial port.
[18:05:58] <cehteh> julius: the delay functions using chip specific instructions and need F_CPU to be defined correctly
[18:06:50] <cehteh> and maybe you had one chip with the CLKSEL8 fuse .. running much slower than you expected?
[18:12:56] <julius> F_CPU is wrong, its 16mhz instead of 8
[18:13:07] <julius> was just wondering why it blinks faster and not slower
[18:14:30] <Lambda_Aurigae> you are sure the one that is running slower was actually running at 8MHz?
[18:14:44] <julius> i received a delivery from china today only took 17 days, thats a new record
[18:15:31] <julius> e4 is the lfuse, 99 the hfuse
[18:15:41] <julius> as shown by avrdude
[18:15:58] <julius> the 32 is set to 8mhz internal with that
[18:16:12] <julius> it does not have a CLKSEL8 setting
[18:16:28] <Lambda_Aurigae> atmega32?
[18:16:33] <julius> h4x0riz3d, they work out of the box
[18:16:34] <julius> yes
[18:17:33] <julius> h4x0riz3d, you can also get some with cp2101 chip - also no linux driver
[18:19:19] <NarwhalX> cp2101 does? The cp2102 does not (only there are problems with arm)
[18:19:22] <julius> h4x0riz3d, with the ftdi chips - i just read that they dont need a driver. i own a cp2101 myself
[18:19:48] <NarwhalX> Ftdi should work our of the box
[18:19:52] <julius> let me check my order, what chip it is
[18:20:35] <NarwhalX> julius: Even though the frequency was wrong,what was the F_CPU define?
[18:22:01] <julius> 16mhz
[18:22:24] <julius> NarwhalX, cant find it in the order currently. ask me in a few hours. need to get some sleep
[18:22:48] <julius> gn8 guys