#avr | Logs for 2013-11-28

Back
[00:04:03] <jerkey> this http://www.atmel.com/devices/ATTINY841.aspx
[00:47:26] <w|zzy> amatuer!
[09:42:37] <Duality> why isn my interupt handled when ItÅ› called when a delay is active ?
[10:11:09] <hetii> Hi :)
[10:12:51] <hetii> I have some strange issue, as i wrote i try porting http://simulationcorner.net/index.php?page=sam to Atmega128.
[10:12:57] <hetii> In such code : http://pastebin.com/hc1cur8T
[10:13:39] <hetii> the Code39771() is called first from main(). After Init(); my Atmega restart itsself all the time.
[10:14:42] <Fornaxian> well, for starters you don't return anything in code39771()...even though you declare it as returning an int.
[10:14:57] <Fornaxian> that shouldn't cause a restart but will cause issues with the compiler.
[10:15:59] <Fornaxian> and, how much ram do those variables take?
[10:16:04] <Fornaxian> the ones in init..
[10:17:02] <hetii> Fornaxian: it was just a part of this method here is the full source: http://pastebin.com/j5AuZ7D2
[10:18:16] <Fornaxian> I'm betting your variables are getting close to filling up heap space.
[10:18:20] <Fornaxian> all those arrays.
[10:18:34] <hetii> yep its the next question, how much ram i need and how can i know that :)
[10:18:40] <Fornaxian> well,
[10:18:58] <Fornaxian> each of those unsigned character arrays is 256 bytes plus overhead.
[10:19:06] <Fornaxian> so, 2560 for the 10 in that first loop.
[10:19:14] <Fornaxian> plus all the other stuff.
[10:19:23] <Fornaxian> you are well over 3K in variables minimum.
[10:19:35] <Fornaxian> that chip has 4K of sram.
[10:19:46] <Fornaxian> you have some system overhead that takes up some of your sram.
[10:20:06] <Fornaxian> I suggest running it through atmel studio and seeing if it can tell how much ram is used..I think it has that capability.
[10:21:04] <Fornaxian> all in all, I'm betting you are hitting the ram limit which is causing that thing to reboot...when heap and stack meet you end up with an error and the chip reboots.
[10:21:28] <hetii> hmm i need check if its written for linux system, and then check by it :)
[10:21:45] <Fornaxian> atmel studio is windows only.
[10:21:56] <hetii> sad :(
[10:22:19] <Fornaxian> which is why I don't use it.
[10:22:44] <hetii> any other way to determine that ?
[10:23:12] <Fornaxian> jtag debugger
[10:23:25] <Fornaxian> or look at all of your variable definitions and figure out how much they use for starters.
[10:25:20] <Fornaxian> and I don't see a main() function in your code anywhere.
[10:26:57] <hetii> yep its here in main.c: http://pastebin.com/WSeDsb0a and here are my prototype board stuff: http://pastebin.com/fBEBmznw
[10:28:23] <hetii> well but i also suppose that 4KB of ram is not enough, so at the and of the day i need use other chip or add to this some external memory.
[10:28:36] <Fornaxian> I would throw it on an atmega1284 chip and see what happens myself.
[10:28:46] <Fornaxian> but, I happen to have a dozen or so of them laying around already.
[10:28:50] <Fornaxian> they have 16K of sram.'
[10:29:36] <Fornaxian> also runs faster than the atmega128
[10:31:24] <Fornaxian> ok..heading for the dungeon.
[10:31:39] * Tom_itx puts a ball and chain on Fornaxian
[10:32:05] <hetii> Well currently i have just my atmega128 so it take me a while to prepare some other board... But if you want to play i can send my sources to you in tar and you can plan with it a while :)
[11:08:16] <isthatme> hrrmmm...
[11:08:28] <isthatme> looking at the attiny45 datasheet
[11:09:07] <isthatme> there are three Clock Select bits in the timer/counter control register
[11:09:38] <isthatme> and several selections mean clk/8
[11:09:44] <isthatme> or clk/1024
[11:09:48] <isthatme> or stuff like that
[11:09:54] <isthatme> exactly what does that do?
[11:10:15] <isthatme> does clk/8 count once every 8 cycles or something?
[11:13:10] <Tom_itx> divides the main clock down for the timers
[11:14:08] <Tom_itx> also known as a prescalar
[11:14:35] <isthatme> yeah... but I'm not sure as to what it does to the timer...
[11:14:43] <isthatme> if it prescales to clk/8
[11:14:57] <isthatme> what is the output
[11:15:01] <isthatme> compared to the timer?
[11:16:16] <Tom_itx> if it's running at 8Mhz it will be 1Mhz
[11:16:45] <isthatme> ooh
[11:16:46] <isthatme> okay
[11:16:52] <isthatme> thanks, that's all I wanted to know
[11:36:59] <isthatme> also, if you reset the timer source (be it prescaler, or external source), does the timer reset?
[12:01:11] <isthatme> nevermind....
[12:08:18] <rlc> How do I know what frequency the cpu clock is running at?
[12:10:43] <isthatme> rlc: check the datasheet
[12:10:49] <isthatme> which avr are you using?
[12:20:12] <rlc> atmega16m1
[12:20:22] <rlc> with can module
[12:26:36] <isthatme> do you currently have the datasheet?
[12:28:22] <rlc> yes
[12:29:17] <isthatme> find any section that references system clock
[12:29:27] <rlc> It seems to me that the default frequency is 1MHz
[12:29:39] <isthatme> it probably is, hrmmmm
[12:29:42] <rlc> Is that possible?
[12:29:53] <rlc> Why not 8Mhz?
[12:29:56] <isthatme> I know attiny default freq is 1
[12:29:58] <isthatme> MHz
[12:30:01] <isthatme> ermmm
[12:30:07] <rlc> The internal oscillator is 8MHz
[12:30:10] <isthatme> write a simple blink program
[12:30:17] <isthatme> using the util/delay.h
[12:30:19] <isthatme> library
[12:30:31] <isthatme> and define F_CPU as 1000000UL
[12:30:46] <isthatme> then, if it blinks 8 times too fast
[12:30:50] <isthatme> it's 8Mhz
[12:31:01] <isthatme> else, it's 1 Mhz
[12:31:09] <isthatme> (or the corrosponding speed)
[12:31:38] <Tom_itx> i think ckdiv8 is set by default
[12:32:04] <Tom_itx> you're getting mixed up on that
[12:32:18] <Tom_itx> when those are set right, it works correctly
[12:32:26] <isthatme> Tom_itx: ?
[12:32:28] <rlc> Tom_itx: so to get it work at max speed I remove the ckdiv8 bit?
[12:32:34] <Tom_itx> yes
[12:32:37] <isthatme> nvm
[12:32:46] <Tom_itx> it's the same as setting the prescalar bits
[12:32:53] <Tom_itx> only they do that for you in the form of a fuse
[12:34:00] <rlc> Can we set/reset the fuse in software?
[12:34:23] <Tom_itx> you may be able to, i can't honesly remember
[12:34:45] <Tom_itx> you _can_ change the register values
[12:34:59] <Tom_itx> i'm not sure how many clock cycles it takes to take effect
[12:39:44] <Fornaxian> rlc, you can't set fuses in software on the machine but the clock prescaler on many chips can be changed in software.
[12:41:04] <rlc> How do one generally set the fuse?
[12:41:47] <rlc> Manually for each single target device?
[12:41:51] <isthatme> you can use an ICSP
[12:41:59] <isthatme> to manually set the fuses
[12:42:05] <isthatme> (yes, for each device
[12:42:07] <isthatme> )
[12:44:03] <rlc> Is there a line I can add at beginning of my C code to set the fuse? Like #pragma something?
[12:44:42] <Tom_itx> i'm not sure
[13:01:51] <blathijs> rlc: Setting the fuses can be done by calling avrdude with the right options, just like uploading your program. If you use some IDE for uploading that hides the avrdude details, perhaps it also has something to set the fuses for you.
[13:57:48] <Enma_Hinobara> Hmm. Arduino-killer spotted? http://linuxgizmos.com/arduino-compatible-boardset-runs-linux-on-x86/
[13:58:08] <Enma_Hinobara> Has SATA and PCI-E
[13:58:19] <Enma_Hinobara> 300 MHz, same price as Arduino
[13:58:40] <specing> 300 MHz in 2013?
[13:58:42] <specing> REALLY?
[13:58:45] <specing> REALLY??!?!?!!?!?!?
[13:59:22] <specing> I'd like to see that thing process PCI-E data
[13:59:37] <specing> because it wont even come close to the bandwidth
[13:59:44] <specing> same with SATA
[14:00:55] <malinus> Enma_Hinobara, it's cool that it's x86. You can probably run lot of stuff on it.
[14:40:07] <amee2k> Enma_Hinobara: thats like the same price range as a dozen embedded ARM boards
[15:21:28] <AndreeeCZ> hello!
[15:21:36] <AndreeeCZ> im interrupting at 40khz and i need a random number every time. do you know of a very dirty and cheap way to do it?
[15:24:57] <OndraSter_> ADC
[15:25:00] <OndraSter_> and noise generator or something
[15:25:22] <OndraSter_> antenna-style noise generator :D
[15:25:45] <OndraSter_> how much random does it have to be?
[15:26:53] <AndreeeCZ> OndraSter_: well more or less evenly spread, but i couldn't care less about predictability
[15:27:22] <AndreeeCZ> need numbers between 0 and 10000
[15:27:48] <OndraSter_> hmmm
[15:28:05] <OndraSter_> your best bet is ADC (and then multiply it to get the proper range)
[15:28:25] <OndraSter_> and some very-temperature dependant resistor (network) or diode or something
[15:28:30] <OndraSter_> ok maybe not temperature
[15:28:55] <AndreeeCZ> so basically no way to do it by software
[15:29:04] <OndraSter_> not enough to make it random
[15:29:12] <OndraSter_> you could make another timer run at some much higher frequency
[15:29:25] <OndraSter_> (not any multiple of the 40kHz though)
[15:29:51] <OndraSter_> if you make it something like 2.7324 times faster, it will take some time before it will making the same pattern
[15:30:18] <AndreeeCZ> well i dont mind patterns too
[15:30:27] <OndraSter_> so do it this way then
[15:30:59] <AndreeeCZ> so I should make another interrupt and do what there?
[15:31:03] <OndraSter_> no interrupt
[15:31:05] <OndraSter_> just let it count
[15:31:16] <OndraSter_> and when your main interrupt (counter) fires up, read the value
[15:31:19] <OndraSter_> of TCNT
[15:31:26] <OndraSter_> and normalize it
[15:33:13] <AndreeeCZ> ok. I dont know what tcnt is
[15:33:21] <OndraSter_> datasheet
[15:33:33] <OndraSter_> "Timer CouNT" register
[15:33:35] <AndreeeCZ> timercount!
[15:35:24] <AndreeeCZ> ok i'll try that
[15:35:34] <AndreeeCZ> seems like the only option
[15:35:55] <AndreeeCZ> thank you guys
[15:35:59] <AndreeeCZ> bye
[15:36:01] <OndraSter_> np
[15:36:18] <OndraSter_> hm, same country, same name
[15:36:21] <OndraSter_> but surely not same surname ;D
[15:38:29] <Guest24530> hello, i have a real hard time setting fuses with avrdude using an jtagice3
[15:38:57] <Guest24530> avrdude -c jtag3 -P usb -p atmega1284p -U lfuse:w:0xe2:m -U hfuse:w:0x10:m -U efuse:w:0xff:m -F
[15:39:04] <Guest24530> is the command that i use
[15:39:10] <Guest24530> and it finishes with :
[15:39:23] <Guest24530> avrdude: safemode: Fuses OK (H:FF, E:10, L:E2)
[15:39:57] <Guest24530> so e an h fuse are exchanged, for the values i set . any idea what that might be ?
[15:41:10] <jerkey> use this web app to figure out what your fuse settings are and what you want them to be. http://www.engbedded.com/fusecalc
[15:41:30] <jerkey> be careful Guest24530 because if you set the fuses wrong, you won't be able to program the chip without a "high voltage programmer"
[15:43:15] <Guest24530> well my problem is that i know the fuses i have to set, only avrdude -jtag3 inverts my settings for e and h fuse, the values i enter aree ok, the values that are written differ ???
[15:45:17] <isthatme> Guest24530: and never, ever use -F
[15:46:48] <jerkey> Guest24530 the true issue is that the chip does not store all the bits of the fuses, only the ones it cares about. so the fuses will not always look the same after you program them because some bits flip back to 1 or 0 if they are ignored
[15:46:54] <Guest24530> well my signature is different, it is kind of intended
[15:47:04] <jerkey> how do you have a different signature?
[15:47:46] <Guest24530> well i don't know, you will have to ask the guyes from Hexabus at Frauenhofer they designed it
[15:49:56] <Guest24530> but isn't it strange that high and extende become exactly the inverted value from what i told them to be set ?
[15:55:56] <jerkey> i guess so
[16:02:26] <hjohnson> dang.. the small avr with canbus doesn't do I2c natively
[16:02:30] <hjohnson> so I guess i'll need to bitbang i2c
[19:20:57] <The_Coolest> hey guys
[19:21:43] <The_Coolest> I've got a quick question. I need to save/load data to/from the eeprom. Said data is in a struct. saving or reading a block is easy enough, but say I want to make a 'generic' function which will allow me to save or read a single byte
[19:22:26] <Tom_itx> http://tom-itx.dyndns.org:81/~webpage/abcminiuser/articles/avr_eeprom_index.php
[19:22:30] <Tom_itx> you should read that
[19:22:37] <The_Coolest> Can I use something like offset = &myStruct.mydata - &myStruct;?
[19:25:29] <The_Coolest> the EEMEM is interesting.
[19:27:14] <The_Coolest> oh, not THAT interesting