#avr | Logs for 2013-03-05

Back
[04:28:56] <creep> life on mars ?
[04:36:32] <yunta> well, curiosity rover got flash corruption right after first drilling, can that be a coincidence? I don' think so.
[04:36:52] <creep> :)
[04:37:37] <creep> it has found radioactive waste buried by aliens
[05:50:23] <cxz_> what is the size of int at atmega168a?
[05:50:53] <cxz_> is it 4 byte?
[05:51:22] <Malinuss> cxz_, http://www.avrfreaks.net/index.php?name=PNphpBB2&file=printview&t=39198
[05:52:12] <Malinuss> cxz_, also that's why you want to use the Standard Integer Types instead of char/int etc.
[05:53:13] <cxz_> Malinuss, thanks
[05:53:57] <Malinuss> so no to your question
[05:59:41] <Roklobsta> has anyone messed with zigbee and contiki?
[06:05:47] <creep> i prefer uint8_t uint16_t and uint32_t instead
[06:05:52] <creep> those have fixed size
[06:06:53] <OndraSter_> yep
[06:06:53] <OndraSter_> typedef'd them to u8, u16 and u32
[06:46:39] * RikusW likes u8 u16 u32 :)
[06:46:51] <RikusW> as well as s8 s16 s32
[06:47:03] <RikusW> no more guesswork as to sizes
[06:47:46] <creep> i just autocomplete and stay with the standard :P
[06:49:37] <OndraSter> RikusW, I don't think I have ever used signed numbers on AVR :o
[06:49:39] <OndraSter> yay
[06:52:30] <Horologium> why is there a _t at the end of those uint declarations?
[06:52:44] <OndraSter> I do it for structs too
[06:52:50] <OndraSter> as "_type"
[06:52:54] <OndraSter> myself.
[06:52:59] <Horologium> ok..that makes sense.
[06:53:01] <OndraSter> no idea what is behind atmel's stuff
[06:53:30] <OndraSter> because if I do typedef struct SomeStruct_t {...} SomeStruct_t; then I can make SomeStrct_t SomeStruct;
[06:53:33] <OndraSter> if I do only one instance of it
[06:53:49] <OndraSter> (USB stuff in my case)
[06:54:07] <Horologium> I always name the struct and the struct definition something different...the _t makes it a little easer I guess.
[06:57:02] <cxz_> I will connect a crystal to my atmega onTOSC1 and TOSC2 pins, do I need to connect these pins to the ground as well?
[06:58:16] <Horologium> cxz_, you need to use 22pF caps to connect between those pins and ground..
[06:58:52] <cxz_> I dont have 22 pF capacitor, would it be fine without using any capacitor?
[06:59:10] <Horologium> the oscillator may or may not start.
[06:59:43] <Horologium> if you are doing it on a solderless breadboard there is probably enough stray capacitance there for it to start.
[06:59:48] <cxz_> the smallest cap that I have 1 nF, would it be fine with it? or does it have to be 22 pf?
[07:00:01] <RikusW> OndraSter_: the _t suffix comes from POSIX
[07:00:01] <Horologium> if you are making a circuit board for it, you will experience problems with the oscillator.
[07:00:06] <cxz_> I am using it on a breadboard now
[07:00:33] <RikusW> iirc Linus dislikes it, as do I..
[07:00:44] <Horologium> I buy 22pF caps in bulk just for crystals...not sure what 1nF caps would do.
[07:01:31] <Horologium> you need 2 of them...one for each pin to ground.
[07:02:17] <RikusW> Horologium: you might get away with one
[07:02:25] <Horologium> true.
[07:02:31] <Horologium> and might get away with none too.
[07:02:37] <Horologium> I often do on solderless breadboards.
[07:02:42] <RikusW> can't remember exactly, but iirc putting it on XT1 should do the trick
[07:02:55] <RikusW> (or maybe XT2)
[07:03:05] <RikusW> but its always better to use 2
[07:03:07] <Horologium> as I recall, larger cap means longer delay for startup of oscillator, up to a point.
[07:04:00] <Horologium> for best stability, use value of cap recommended by crystal manufacturer....however, the crystals I buy are pretty much no-name and can't find any kind of datasheet so I just use 22pF.
[07:04:33] <cxz_> Horologium, if I connect the crystal to TOSC1 and TOSC2 without capacitor on a breadboard, should I connect these pins to ground or just keep it as it is? I don't need very precise clock by the way
[07:04:44] <RikusW> 15cm of 0.5 single core wire gives about 10pF and two are twisted toghether..
[07:04:47] <Horologium> if you connect them to ground it won't run.
[07:06:08] <Horologium> RikusW, you can also use paper clips, a sheet of paper, and a #2 pencil to make a resistor too...even a variable resistor!
[07:06:43] <OndraSter_> heh
[07:07:34] <Horologium> now we need to figure out how to make a transistor from some corrosion on a penny and we are good to go.
[07:08:01] <Horologium> can do it as a diode, kindasorta, for a "crystal" radio.
[07:08:55] <RikusW> if he's desperate he can use wires :-P
[07:09:05] <RikusW> I'd use real caps
[07:09:24] <RikusW> 0603 22pF caps ftw :)
[07:09:43] <Horologium> they get lost in the holes of the solderless breadboard.
[07:11:27] <cxz_> Horologium: I have one more question. my atmega's SUT_CKSEL is set to INTRCOSC_8MHZ_6CK_14CK_0MS. I connect the atmega to a spi device as slave. I am trying to set clk frequency of the spi on atmega. I read that SPCR and SPSR's bits are used to set the clock frequency. what clock frequency do I need to refer? Fuse is set at 8 MHz but F_CPU is at 1 MHz by default, so which one should I refer?
[07:11:38] <Horologium> ok, just came up with the perfect billion dollar idea...new holder for iPhones..
[07:11:40] <Horologium> the iCrotch crotch pocket...set your iPhone on vibrate and enjoy your calls.
[07:12:02] <cxz_> without connecting any external crystal
[07:13:04] <Horologium> F_CPU is just a constant set in your program most likely....
[07:13:18] <Horologium> it is used for calculating things like baud rate settings.
[07:13:20] <cxz_> or if I use "SPSR |= (1<<SPI2X); ", will it set the clock at 4 MHz or 0.5 MHz?
[07:13:59] <Horologium> by default from the factory AVR chips are set to 8MHz clock with prescaler dividing it by 8 so it runs at 1MHz.
[07:16:03] <cxz_> how can I set it to 8MHz? do you know why chips are set to run 1 MHz by default? is it bad to run it at 8MHz? or is it just convenient to run it at 1 MHz?
[07:16:27] <Tom_itx> lowest common denominator
[07:16:34] <Horologium> easy math...
[07:16:38] <Tom_itx> clear the ckdiv8 fuse
[07:17:44] <cxz_> thanks
[07:25:40] <Malinuss> cxz_, most chips run at 1MHz by default, because the prescalar is set to 8 by default. So even though they run on the internal 8MHz oscilator, they actually run 1MHz..
[07:26:38] <cxz_> unclicking ckdiv8 will run the chip at 8 MHz, right?
[07:26:40] <Malinuss> cxz_, so if your SUT_CKSEL is set to INTRCOSC_8MHZ_6CK_14CK_0MS, the chip is running at 8MHz, but the prescalar is always set to 8, so just set it to 1 at the start of the program
[07:26:51] <Malinuss> cxz_, what, no
[07:27:02] <Tom_itx> yes it will
[07:27:12] <Malinuss> wait
[07:27:20] * Tom_itx smacks Malinuss
[07:28:35] <Malinuss> Tom_itx, so the ckdiv8 fuse just sets CLKPR to 8?
[07:28:42] <Tom_itx> yes
[07:29:01] <Horologium> yup.
[07:29:16] <Tom_itx> just a convienent way of doing the same thing
[07:29:44] * Malinuss makes a note to change the fuses instead of changing the CLKPR at runtime
[07:30:33] <Horologium> you can change CLKPR on the fly too.
[07:31:01] <Malinuss> Horologium, yeah that's what I always do... Idk. just never noticed the ckdiv8.. haha
[07:31:26] <Horologium> start it with CKDIV8 set so it's running at 1MHz....then vary speed by playing with CLKPR later.
[07:31:50] <Horologium> The CKDIV8 Fuse determines the initial value of the CLKPS bits. If CKDIV8 is unprogrammed,
[07:31:50] <Horologium> the CLKPS bits will be reset to “0000”. If CKDIV8 is programmed, CLKPS bits are reset to
[07:31:50] <Horologium> “0011”, giving a division factor of 8 at start up.
[07:31:59] <Horologium> right in the datasheet!
[07:32:00] <Horologium> hehe
[07:32:30] <Malinuss> Horologium, yeah, I think I never read the text, just looked at the spreadsheet for the CLKPS, and set it that way ;D
[07:32:31] <Horologium> interestingly, you can run a 20MHz device from an 80MHz crystal with that set.
[07:32:56] <Horologium> in theory anyhow.
[07:33:00] <OndraSter_> did I mention today that I ran xmega's core on 80MHz? :P
[07:33:21] <Horologium> OndraSter_, what is their normal max operating frequency?
[07:33:26] <OndraSter_> 32
[07:33:29] <Horologium> I don't have any xmegas.
[07:33:31] <Malinuss> Horologium, you sure? I don't know how the prescalar works on the low level, but could be
[07:33:49] <Horologium> says so in the book.
[07:33:54] <Malinuss> I see
[07:34:01] <Horologium> The Application software must ensure that a sufficient division factor is chosen if
[07:34:01] <Horologium> the selected clock source has a higher frequency than the maximum frequency of the device at
[07:34:01] <Horologium> the present operating conditions.
[07:34:11] <Malinuss> OndraSter_, do some testing, where you are abel to see if the xmega makes any errors, and how often
[07:34:12] <Horologium> or, rather, implies so.
[07:34:13] <Horologium> hehe
[07:34:22] <OndraSter_> Malinuss, I was just blinking LEDs :D
[07:34:27] <OndraSter_> 80 was just crazy
[07:34:31] <Horologium> I've run atmega1284p at 32MHz stable.
[07:34:31] <OndraSter_> 48 should be stable for everything
[07:34:38] <OndraSter_> 64 for most peripherals
[07:34:45] <OndraSter_> I am not sure where is EEPROM getting clocks from
[07:34:48] <OndraSter_> whether core or separate
[07:35:02] <OndraSter_> since EEPROM is pretty much the only peripheral who usually cocks up with higher clocks
[07:35:18] <Horologium> don't think I would want to program flash or eeprom at 32MHz on an atmega1284p but everything else worked fine.
[07:36:11] * Horologium just wishes a regular mega AVR could run code from external memory...even if it meant slowing things down considerably..
[07:36:19] <OndraSter_> yep
[07:36:24] <OndraSter_> on xmega at least
[07:36:39] <OndraSter_> a1(u) series has got external bus interface
[07:36:43] <OndraSter_> supporting SRAM and SDRAM
[07:36:46] <OndraSter_> upto 16MB :P
[07:36:49] <Horologium> having to use 8052 chips for that level of programmability.
[07:36:56] <Horologium> is that for program or data or both OndraSter_ ?
[07:37:01] <OndraSter_> data only
[07:37:05] <OndraSter_> :(
[07:37:09] <Horologium> yeah..that sucks.
[07:37:21] <Horologium> the 8052 has had external program and data access all along.
[07:37:22] <OndraSter_> you could hook up E(E)PROM to it too of course, with not hooking up the write signal
[07:37:24] <OndraSter_> ye
[07:37:26] <Malinuss> OndraSter_, is it a bitch to set up external SRAM? Or just some few settings, and then you do everything as usual and everything happens automagic?
[07:37:30] <Horologium> it slows down to access external but it runs.
[07:37:38] <OndraSter_> Malinuss, well, for gcc or for asm? :P
[07:37:55] <Malinuss> OndraSter_, gcc ;D
[07:38:13] <Malinuss> OndraSter_, asm is good to change a single register or make a simple loop ;D
[07:38:15] <OndraSter_> gcc can't make use of the RAMP* registers
[07:38:16] <Malinuss> at least for me haha
[07:38:20] <OndraSter_> so it can address only 64kB on its own :(
[07:38:30] <OndraSter_> you would have to make bank switching somehow
[07:38:35] <Horologium> Malinuss, on the atmega128 and atmega8515 it was fairly simple...one interface chip for address/data multiplexing and away you go....just set RAMEND and bingo.
[07:38:41] <OndraSter_> yep
[07:38:55] <Malinuss> but that's only for up to 64kB?
[07:39:01] <OndraSter_> I used 128kB SRAM on mega128a
[07:39:06] <OndraSter_> with manual bank switching
[07:39:10] <Horologium> just need a bit of bank switching magic.
[07:39:15] <Horologium> that's how I do it on the 8052.
[07:39:19] <OndraSter_> well for gcc it is not fun
[07:39:27] <Horologium> have a 1MB external NVSRAM.
[07:39:41] <Horologium> and bank switch for both data and program space.
[07:40:40] <Horologium> it is actually possible for the thing to self-program by switching program bank into data space and writing to it there then switch it back to program space....
[07:42:06] <Horologium> having to write my own overseer program so other programs can run with that setup and it is proving a fun and interesting project.
[07:42:33] <Horologium> all programs are limited to 32K of program space and can call other programs in other banks.
[07:42:53] <OndraSter_> yay half of the czech big websites are down, they are being DDoSed!
[07:43:15] <Horologium> userspace programs reside in lower 32K inside of NVSRAM banks, overseer in upper32K in flash on the chip.
[07:49:14] <Horologium> OndraSter_, shouldn't affect me...the czeck sites down thing...
[07:51:00] <OndraSter_> nope
[07:51:05] <OndraSter_> and they fixed it appearantly
[07:51:17] <OndraSter_> I thought the servers were down again
[07:51:23] <OndraSter_> but they have just broken DNS
[07:51:26] <OndraSter_> or idiot admins
[07:51:29] <Horologium> if I had an AVR that could run code from external sram I would drop 8052 completely.
[07:51:35] <OndraSter_> who set up www.somewebsite.cz but not somewebsite.cz
[07:51:46] <Horologium> hehe.
[07:54:53] <theBear> nvsram ? that's err, a funny idea....
[07:56:06] <Horologium> theBear, maxim nvsram....I have them from 32KB to 1MB in dip package...
[07:56:14] <Horologium> sram with battery backup in the package.
[07:56:43] <theBear> OH... i thought it was a prom with sram interface
[07:58:04] <Horologium> http://www.maximintegrated.com/datasheet/index.mvp/id/2675
[07:58:13] <Horologium> nope...sram with built in UPS.
[07:59:04] <theBear> i can't read that, i'm on enough painkillers to kill an elemaphant
[07:59:28] <Horologium> hehe.
[07:59:53] <Horologium> 8Mx8bit sram with built in lithium battery backup.
[08:00:29] <Horologium> and 70ns read/write
[08:00:40] <theBear> hmmm, interesting
[08:01:35] <Horologium> 10 year data retention..
[08:01:47] <Horologium> or rather, 10 year battery life estimated.
[08:02:19] <Horologium> same system as what was used for the clock/cmos chips on motherboards.
[08:02:36] <Horologium> the big honking Dallas chip on motherboards for many years.
[08:02:38] <theBear> they're called rtc chip/modules
[08:03:10] <Horologium> the chip that saved the CMOS system settings and kept the clock when the power was off...just a Dallas NVSRAM module with built in RTC.
[08:03:31] <Horologium> maxim bought dallas semi some years back.
[08:03:48] <Horologium> their newest line have a replaceable battery.
[08:04:44] <Horologium> the chips with built in battery come with the battery disconnected....a little flipflop or something that doesn't turn on until you apply power for the first time...then it stays on constantly whether you apply external power or it runs on internal battery.
[08:06:37] <theBear> trust me, it's called a rtc chip or module, depending on the size/shape
[08:07:21] <OndraSter> NVSRAM != RTC
[08:07:28] <OndraSter> SRAM keeps data, RTC does time
[08:08:02] <theBear> yeah, we both know that bit
[08:08:11] <OndraSter> I didn't read backlog :D
[08:10:36] <Horologium> I knwo what it is called...but the Dallas RTC modules that have the storage in them are just an SRAM, RTC, and battery backup in a module....the SRAM and battery backup in them are the same as the maxim/dallas NVSRAM modules.
[08:10:59] <Horologium> older ones didn't have internal battery.
[08:11:18] <Horologium> then they did...
[08:11:29] <Horologium> and now they are going back to external battery again it seems.
[08:18:47] <Horologium> .....oops...earlier...that should have been 1Mx8bit sram.
[08:32:21] <cxz_> I have 28 pin atmega168a, I have been powering avr dragon with an spi connection. I will disconnect the dragon and supply another external power, in this case, is it sufficient to have connection on VCC and GND pins? or would I need to connect PCINT14/RESET to VCC with 10 k resistor?
[08:35:21] <Horologium> need, no,,,good practice, yes..
[08:35:30] <Horologium> or even 100Kohm.
[08:38:12] <blathijs> Hi guys. Not sure if this is the right place for this question but I'm wondering if avr-gcc 4.8 has support for linker plugins (for lto) or if support is planned? I've tested 4.7, but it seems it doesn't work there...
[08:44:25] <cxz_> I am trying to test if the atmega 168a gets interrupt when it receives data from a spi device. here is my very short code http://pastebin.com/BkGRxAxc I connect leds to portC. is the spi and interrupt usage correct on my code?
[08:49:08] <OndraSter> cxz_, do you enable anywhere the SPI interrupt
[08:49:08] <OndraSter> I can't see it :)
[08:50:34] <cxz_> I have SPCR |= (1<<SPE); on line 12, doesn't it enable spi interrupt?
[08:57:33] <cxz_> OndraSter, is it correct to use SPCR |= (1<<SPE) to enable spi or do I need to have another line to do it?
[09:00:21] <OndraSter> blimey, the datasheet is 35MB, I am not going to download that right now
[09:00:21] <OndraSter> it should be something like SPIE
[09:00:21] <OndraSter> SPE enables just the SPI interface
[09:03:03] <cxz_> OndraSter: yes I see it on the datasheet, I will fix the code now
[09:03:04] <cxz_> thank you
[09:03:43] <OndraSter> np
[13:57:02] <megal0maniac> Can 72.41 ever be a valid octal number?
[13:57:23] <megal0maniac> Or 101.01 in binary for that matter
[13:57:49] <megal0maniac> (yes, that is a decimal point)
[13:58:31] <Roklobsta> i think so. why not?
[13:58:41] <Roklobsta> not everything has to always be > 0
[13:59:15] <Roklobsta> 0.01 in binary is 0.25 in decimal
[13:59:33] <megal0maniac> I've never seen it, and my calculator doesn't believe in it.
[13:59:56] <Roklobsta> welp, i rem doing that stuff in 1st year uni and also have used it for fixed point maths.
[14:00:21] <megal0maniac> Hmm.. Okay, thanks
[14:01:08] <megal0maniac> We're being asked to multiply 72.41 by 5.6 (all oocyt
[14:01:09] <Horologium> how you express it depends on what system you are using.
[14:01:14] <megal0maniac> octal
[14:01:29] <Horologium> not base, system
[14:01:40] <megal0maniac> Horologium: just on paper for now
[14:01:49] <Horologium> converting it to full floating point?
[14:02:02] <Horologium> or just do it as an extension of regular integer math?
[14:02:26] <Roklobsta> octal is, oh, some kid of sickness from the 1950's.
[14:02:35] <megal0maniac> Regular integer math, I suspect. It's first year number systems
[14:03:39] <megal0maniac> Roklobsta: I've found it useful for permission masks in Unix and little else
[14:04:15] <Roklobsta> oh well, the neckbeards who created UNIX cut their computer teeth in the 50's
[14:05:05] <Horologium> one would think, doing it on paper, you just flip everything around south of the decimal point.
[14:05:10] <Roklobsta> ok UNIX permissions aaaand....?
[14:05:20] <Horologium> or not...
[14:05:25] <Horologium> heck, that's too hard to think in.
[14:05:27] <Roklobsta> it's no different to decimal.
[14:05:38] <Horologium> 255.255 would be ff.ff
[14:05:40] <Horologium> I guess.
[14:05:50] <Horologium> 0xff.ff
[14:05:58] <Horologium> so no flip around..just do it.
[14:06:11] <Horologium> all you are doing is moving the decimal point over.
[14:06:54] <Roklobsta> 0.1 in binary is 1*2^-1 and 0.01 is 1*2^-2
[14:07:08] <Horologium> guess I'm wrong all the way around.
[14:07:11] <Roklobsta> so in octal 0.4 is 4*8^-1
[14:07:17] <Horologium> is what I get for being sick and trying to think...or just trying to think.
[14:07:34] <Roklobsta> and 0.07 is 7*8^-2
[14:07:35] <Roklobsta> etc
[14:09:19] <Tom_itx> what os used octal?
[14:09:48] <Tom_itx> or language for that matter
[14:11:09] <megal0maniac> What is the modern way of dealing with decimal points?
[14:11:31] <megal0maniac> Tom_itx: only Unix that I know of
[14:11:35] <Horologium> double a=1.441225;\
[14:11:37] <Horologium> double a=1.441225;
[14:12:27] <megal0maniac> Yes, but at binary / compiler level?
[14:12:31] <Roklobsta> modern way? Like New Math?
[14:12:42] <Roklobsta> in Europe I think they use , instead of .
[14:13:17] <Roklobsta> that's some stupid Euro-quirk mandated by the WeKnowBetterThanYou's in Brussels.
[14:14:11] <Horologium> megal0maniac, look at the floating point code in libc/avr-libc
[14:14:37] <megal0maniac> So floating point is essentially the answer?
[14:14:46] <Horologium> 0x412028f6 = 10.01
[14:15:20] <megal0maniac> :/
[14:15:27] <Horologium> there are also some fixed point math routines out there.
[14:16:46] <Horologium> simplest would be to multiply the input by 100 or move the decimal point over...then do all your math...then move it back when done.
[14:21:13] <megal0maniac> Awwww this is horrible
[14:21:41] <megal0maniac> Tobbor?
[14:23:00] <Roklobsta> actually it's easy
[14:23:23] <megal0maniac> Difficult to conceptualise
[14:24:35] <Roklobsta> what computatyions are you trying to do?
[14:25:54] <Horologium> you do octal or hex just like you do decimal or binary.
[14:26:25] <Roklobsta> with a calculator
[14:26:52] <megal0maniac> Well for one, 72.41 x 5.6. Base 8
[14:27:52] <Horologium> multiply it out...6*72.41 and 5*72.41*10...add the two together and move the decimal point over 3 places...only do your math in base 8 rather than base 10
[14:28:43] <Horologium> err... 6*7241 and 5*7241
[14:29:08] <Horologium> and not multiply by 10 but add a 0.
[14:29:19] <Horologium> glub...confusing even myself ain't I?
[14:29:19] <Roklobsta> yes, in octal 8 is 10
[14:33:19] <Horologium> so, you basically ignore the decimal points and do the math,,,in octal or whatever base....then add in the decimal points afterwards.
[14:34:02] <Horologium> so, answer is 520.365 ??? I think?
[14:37:29] <megal0maniac> It is, according to that logic. I think this makes sense..
[14:38:42] <Roklobsta> there are 10 kinds of people who underatand binary.
[14:39:59] <megal0maniac> And C0FFEE = 12648430
[14:43:05] <OndraSter> what about FACEB00C
[14:43:58] <megal0maniac> What would 0.1 (bin) be in hex?
[14:44:25] <megal0maniac> 0.8?
[14:58:38] <megal0maniac> Yes it is :)
[14:58:47] <megal0maniac> XBOARD
[15:09:58] <megal0maniac> Thanks Horologium. I'm off to bed, had enough for one night ;)
[18:15:46] <tzanger> hm, I wonder if I can multiplex an I2C slave and a half-duplex UART with the UCI
[18:18:03] <tzanger> they seem to have labelled the UCI pins on the ATTINY25 as a slave
[18:18:28] <tzanger> PB0 = MOSI/DI, PB1 = MISO/DO
[18:58:57] <n17ikh> so I have here an atmega328p that was purported to be from an arduino
[18:59:05] <n17ikh> are those things set up to use an external crystal?
[18:59:24] <n17ikh> cause my usbtiny programmer doesn't see it, and that's about all I can think of
[19:01:44] <damjan> n17ikh: yes, they use a crystal
[19:02:43] <n17ikh> hopefully I'll be able to dig one up
[19:02:47] <n17ikh> speed shouldn't be critical, right?
[19:02:50] <n17ikh> just need to clock the chip?
[19:03:51] <Aleks> n17ikh, anything above 8MHz should work
[19:04:09] <n17ikh> alright, thanks