#avr | Logs for 2014-06-06

Back
[09:55:12] <Roter> Hey guys, i just got a atmega328P. The problem is that when i connect it to atmelstudio, it says:
[09:55:13] <Roter> Unable to enter programming mode.
[09:55:13] <Roter> Please verify device selection, interface settings, target power and connections to the target device.
[09:55:49] <Roter> I tried setting the isp clock to the lowest, i selected correctly the device
[09:56:36] <Roter> A strange thing is that it shows, that the target voltage is 3V, while when i check it on a multimeter, it says 5V
[09:56:52] <Roter> Also, what should i set the clock generator?
[10:10:59] <cyber37> Did someone know why when i try to affect a value to a int16_t my avr "crash" ?
[10:13:43] <cyber37> when he is declared global it crash
[10:14:05] <cyber37> if he is declared localy it works, but i need it in global
[10:14:22] <cyber37> Why did it crash in global ? did i loose something ? something to know ?
[10:16:02] <Roter> Does AREF must be connected to VDD on an atmega chip?
[10:19:30] <Roter> i believe i can connect it to just power, seems logical that way.
[10:20:31] <Roter> Another small question, do i have to connect ground of my programmer or i can just leave it not connected, because i have a seperate power supply
[10:20:55] <myself> Roter: What does the datasheet say?
[10:27:06] <megal0maniac> Roter: If you have a seperate power supply, then you HAVE to connect ground
[10:27:28] <megal0maniac> And as myself said, the datasheet will advise you on how to connect AREF
[11:16:42] <malinus> you only need to connect the reference, if you are using it
[11:19:52] <Roter> i connected ground too, but the problem now is it says: Unable to connect to tool STK500 (COM4) . So it looks like i have wired something wrong
[11:26:10] <Roter> ahh great.. It was sleeping. Now its time to continue on seeing, why the voltage is 3V, while the external power source is set to 5V
[11:32:20] <Roter> Thank god, i fixed it, thanks you guys for telling me about the ground thing
[11:32:36] <twnqx> be careful with your ground!
[11:32:50] <twnqx> i once accidently connected gnd of device 1 with plus 5V from device 2
[11:32:57] <twnqx> the resulting -5V were deadly.
[11:42:27] <Roter> Alright, will keep in mind
[12:04:08] <cyber37> Hi, did someone know how to "help" a SPI communication to work ? for exemple adding capacitor's or something else ?
[12:08:11] <Kev> cyber37, i had issues with nrf24l01+ wireless modules
[12:09:26] <Kev> adding a cap helped, but i'm fairly sure that it was not an spi issue but those modules being too sensitive
[12:12:04] <Jartza> hmmh
[12:12:16] <Jartza> maybe I got the timers in attiny85 a bit wrong
[12:13:27] <Jartza> someone care to comment if I pastebin?
[12:13:29] <Jartza> http://pastebin.com/UWhe0Cuf
[12:13:31] <N1njAway> SPI generally doesn't need any external components on the bus to work properly, however if you are going over very long wires that are not on a PCB or do not have a ground plane reference it's possible that you may require termination and/or a very small capacitor to help control ringing and edge rates.
[12:13:33] <Jartza> well I did anyway :)
[12:13:42] <Jartza> did I understand the datasheet correctly?
[12:14:07] <Jartza> I'm trying to make the timer to increase the 8-bit counter at 125kHz speed
[12:14:29] <Kev> btw i didn't meant a cap on the data bus, but between vcc and gnd very close to the module
[12:14:41] <N1njAway> I have seen single-bit errors occur on long runs of SPI over 8-10" of ribbon cable from a dev board, and the extra parasitic capacitance/inductance of adding logic analyzer probles completely eliminated them.
[12:14:49] <Jartza> so it should overflow around 488 times / sec?
[12:14:52] <myself> Heisenbug!
[12:15:07] <Jartza> does my pastebin look even closely correct
[12:15:10] <Jartza> :)
[12:15:25] <N1njAway> Kev: You should always provide as many 0.1uf caps as close to digital logic on every supply pin possible.
[12:16:04] <N1njAway> You can start to get extremely difficult to troubleshoot and erratic behavior from devices if you don't have extremely clean rails.
[12:16:47] <myself> Hehe. Yeah, my first troubleshooting step is to sprinkle little caps everywhere.
[12:16:48] <N1njAway> I don't know your configuration, but if your module is "away" from a supply (such as on longer wires, etc) then a couple larger tank caps in the 10uF range may be a good idea.
[12:16:49] <Jartza> or did I even understand correctly that the attiny85 "asynchronous clock" ticks at 64MHz?
[12:17:29] <N1njAway> Jartza: The timers on AVR devices generally run either at the clock speed or some divisor thereof depending on how you set the bits.
[12:17:57] <Jartza> hmmh
[12:18:08] <Jartza> "Timer/Counter1 and the prescaler allow running the CPU from any clock source while the prescaler is operating on the fast 64 MHz (or 32 MHz in Low Speed Mode) PCK clock in the asynchronous mode."
[12:19:24] <N1njAway> I've not used that particular mode in the Tiny85 before.
[12:20:39] <N1njAway> Unless the PCK clock is PLL'd against the system clock, and assuming you are using an external crystal or resonator, you need to be sure how much accuracy you need in the timers for your application.
[12:26:54] <Kev> N1njaneer, i usually go with one big one and one smaller one in parallel
[12:30:14] <Jartza> N1njAway: not that "huge" accuracy, but I'm more or less wanting to get the ballpark right :)
[12:30:41] <Jartza> "To set Timer/Counter1 in asynchronous mode first enable PLL and then wait 100 μs for PLL to stabilize. Next, poll the PLOCK bit until it is set and then set the PCKE bit."
[12:31:09] <Jartza> I tried to follow that information :)
[12:33:39] <Jartza> just that the timer still seems to be much much faster than I thought
[12:35:19] <Jartza> (or I just can't count :)
[12:36:55] <Jartza> I'm basically feeding external interrupt around 10kHz speed, reading the value of TCNT1 and after that setting it to 0
[12:37:34] <Jartza> if I understood correctly, I should be getting counter values around 12-13..
[12:37:44] <Jartza> but the values are >50 all the time
[12:38:09] <Jartza> d'oh
[12:40:44] <Jartza> "PCKE: PCK Enable
[12:40:46] <Jartza> The PCKE bit change the Timer/Counter1 clock source. When it is set, the asynchronous clock mode is enabled and fast 64 MHz (or 32 MHz in Low Speed Mode) PCK clock is used as Timer/Counter1 clock source."
[12:40:58] <Jartza> says the datasheet about the "PLLCSR – PLL Control and Status Register"
[12:41:48] <Jartza> I don't have the "LSM: Low Speed Mode" - bit set.
[12:42:00] <Jartza> and the prescaler should be 512...
[12:42:44] <Jartza> 64M / 512 / 10k should be 12.5??? :)
[13:33:21] <Jartza> hmm
[13:33:46] <Jartza> the timer value still reads more like ~40
[13:37:56] <Jartza> or maybe attiny85 can't handle 10k interrupts / sec with 8MHz? :)
[13:39:11] <N1njAway> Nah 10K interrupts should be fine at 8 Mhz
[13:39:30] <Jartza> d'oh
[13:39:43] <Jartza> then there's something I don't get with the counter :)
[13:40:01] <N1njAway> Do be aware that there's pretty considerable overhead with interrupts on AVR in how gcc generally handles the code - there's usually a lot of stack thrashing for registers push/pop, so if you are not getting the performance expected check the .lss file to see all of what is happening in your interrupt calls.
[13:40:50] <N1njan33r> Oops, left home PC logged in with my regular nick :D
[13:40:54] <Jartza> sure
[13:41:10] <Jartza> I know there's overhead, but still, the value is like 3 times what it should be
[13:42:06] <Jartza> like 18 pushes and few i's and outs
[13:42:11] <Jartza> ins
[13:43:21] <N1njan33r> I've done some very data-intensive applications that had a constant torrent of 250kbaud data in each of the four serial ports on a 2560, and resend of data out of the same four serial ports after heavy processing, and all real-time deadline. It was far better performance to simply not use interrupts at all and manually do polling and processing in a large interleaved mainline - allowed very easily
[13:43:21] <N1njan33r> measuring the min/max processing times for the loop (via GPIO toggles) over many hours with a digital o'scope to ensure there was never the possibility of lost data due to just the wrong combination of operations occuring.
[13:43:51] <N1njan33r> Jartza: Sounds about right. Sometimes that's a lot of overhead, though, if you have either a bunch of interrupts expected, or a very frequently occuring interrupt
[13:44:26] <Jartza> I lowered my number of interrupts to 2.5k now
[13:44:58] <N1njan33r> i.e. if you have 25-30 cycles of pre/post-amble to interrupt processing on a 10Khz interrupt, that's 250,000 cyles burned per second, or basically 1/16th of your total CPU budget zapped just to interrupt processing overhead. :)
[13:45:31] <Jartza> sure
[13:45:51] <Jartza> I was just wondering if there's something I don't get with the timers
[13:45:57] <Jartza> and I still don't have the scope :)
[13:46:17] <Jartza> I ordered el cheapo oscilloscope, but I haven't got it eyt
[13:46:29] <N1njan33r> (Excuse me, 1/32th above - I can't math today it seems)
[13:46:39] <N1njan33r> The timers are sometimes a bit tricky.
[13:46:46] <Jartza> yeah
[13:47:06] <N1njan33r> Not sure if the 85 has it, but there's a CLKDIV8 fuse that can sometimes getcha if you're not aware that it's set by default.
[13:47:14] <Jartza> of course I could have enabled the comparator output and measured that with oscilloscope... if I had one :D
[13:47:30] <N1njan33r> Also making sure you are selecting the external clock as the source, assuming you are using one, rather than internal oscillator
[13:47:37] <Jartza> yeah, t85 has it, but it's not set
[13:47:54] <Jartza> I'm still using internal as t85 only has 8 pins :)
[13:47:55] <N1njan33r> If it's slow enough, measure the TTL waveforms with your soundcard in a pinch :)
[13:51:48] <Jartza> I ordered this: http://www.ebay.de/itm/Hantek-DSO5102P-USB-Digital-Storage-Oscilloscope-2-Channels-100MHz-1GSa-s-/321410038427
[13:51:51] <Jartza> :)
[13:52:02] <Jartza> el-cheapo, but I guess still way better than just a multimeter :)
[13:56:54] <Jartza> but because I've never used one, I guess that's fine for learning with el-cheapo hardware too :)
[14:03:24] <Jartza> aaaaargh
[14:03:35] <Jartza> found the fault :D
[14:03:48] <Jartza> I had too much going on with my breadboard
[14:04:01] <Jartza> I had 1k pulldown on the interrupt-pin
[14:04:21] <Jartza> I was actually just missing interrupts
[14:05:00] <Jartza> now I get values between 15-16 which considering the overhead sounds about right
[14:06:47] <Jartza> and pushing interrupts to 44.1kHz I get values between 2-3
[14:06:52] <Jartza> so the timer was correct... d'oh
[14:51:54] <Jartza> current version of the modem + uart tx is 404 bytes
[14:51:57] <Jartza> I guess that's ok :)
[14:56:19] <Jartza> I'm pretty sure I could make it much faster, but I guess the biggest problem now is my analog side of the circuit :)
[14:56:48] <Jartza> and I have only a vague clue what's going on in there, but as I don't have the oscope, I can't be sure
[15:08:38] <Jartza> oh well. already made it faster :)
[15:09:44] <Jartza> -rw-rw-r-- 1 jartza jartza 153680 Jun 6 22:29 pg45879.txt
[15:09:53] <Jartza> 3m38.515s
[15:10:48] <Jartza> around 5600bps if I count correctly
[15:30:41] <Jartza> uhh
[15:31:11] <Jartza> this is quite nasty without oscope, but hey, >6000bps
[15:31:26] <Jartza> Program: 406 bytes (5.0% Full)
[15:35:08] <Jartza> I think I have to start making the uart faster soon :)
[15:35:13] <Jartza> maybe 230.4k
[15:35:22] <Jartza> well, not yet :)
[16:00:54] <Jartza> 199.800s / 153680 bytes
[16:00:56] <Jartza> :)
[16:01:08] <Jartza> https://www.dropbox.com/s/h2shqqpfm055uxa/VID_20140606_233651.mp4
[16:01:22] <Jartza> I guess it's best I can do without scoping
[16:20:04] <malinus_> Jartza, what am I watching :)?
[16:50:51] <Jartza> malinus_: playing audio from android cellphone, attiny85 is "listening" and demodulating that audio to bits :)
[16:50:58] <Jartza> and echoing them back through rs232
[16:52:49] <Jartza> just a learning process for me :D
[16:55:00] <Jartza> the receiving end is 18 lines of C now :)
[16:55:09] <Jartza> and the whole binary including the uart is 404 bytes
[16:55:22] <Jartza> but I aim to make it better
[17:34:04] <malinus_> Jartza, sounds like a fun project. I was kinda doing the opposite. I was reading .wav files from a SD card using a mcu, and then playing it.
[17:34:18] <malinus_> (actually I was transmitting it with AM, but yeah)
[17:34:18] <Jartza> cool
[17:34:29] <Jartza> I haven't even thought of any storage media yet :)
[17:34:45] <Jartza> decided to start small, I'm relatively new to avr
[17:34:59] <Jartza> and really new to making my own electronic circuits
[17:35:01] <malinus_> Jartza, also it was using my own made-up file-system on the SD. It was very simple, but all I needed for that.
[17:35:18] <malinus_> Jartza, yeah you don't need any storage media normally.
[17:35:20] <Jartza> sounds fun
[17:40:21] <N1njan33r> FAT16 is relatively easy to do on SD Cards via SPI bus. Have done that as well. Nice to be able to place files on with an OS and then pull them back off with the micro
[17:40:37] <Jartza> that's cool
[17:40:42] <Jartza> SPI is simple
[17:40:56] <N1njan33r> It is at least when you're a master :)
[17:41:13] <Jartza> yes :)
[17:41:34] <Jartza> hmmh. now my modem syncs nicely to different speeds too
[17:42:37] <Jartza> from 2800bps to 6000
[17:43:19] <Jartza> pride & prejudice (the book) transferred in 15m 55s :D
[17:43:28] <Jartza> 717569 bytes
[17:44:04] <Jartza> I was already guessing that if I lose the uart, I might get even higher speeds
[17:45:10] <Jartza> currently I'm using pin change interrupt, but I was thinking that what if I use INT0 and set it to rising edge only
[17:45:31] <Jartza> and instead of measuring the pulse, just measure the time from rising edge to rising edge
[17:45:34] <Jartza> hmm
[17:45:38] <Jartza> would save some code :D
[17:45:58] <N1njan33r> Could work, yeah :)
[17:48:01] <Jartza> that would halve the amount of interrupts
[17:48:56] <Jartza> oh well... maybe I wait for the oscope and first see what actually happens on the pin :)
[17:49:21] <Jartza> because just a small fiddling with my analog part made a big difference already, got the speed to 6kbps
[17:49:39] <Jartza> even from phone :)
[17:57:01] <malinus_> N1njan33r, I've started reading and then tried implementing FAT16, then I've looked into the different extX. In the end I figured it would be easiest to just hack something together. And I think it was
[17:57:33] <malinus_> I didn't need a file system that had all kind of bloat data, like access times etc.
[17:57:52] <malinus_> I've just made a script that could copy whatever files I needed, to the SPI
[18:00:48] <Jartza> fuschia
[18:01:10] <Jartza> it also works with just counting the time between rising edges
[21:17:37] <N1njaneer> Quiet night again!
[21:17:42] <N1njaneer> *crickets*
[21:44:37] <myself> it's Friday night.. And first Friday, at that.
[22:10:08] * akoimeexx has been in and out of his workshop glaring at a proprietary chip and debating using a tiny85 instead. For the last day or so.
[22:14:36] <Tom_itx> stop debating with yourself, nobody will win
[22:23:38] <Casper> friday isn't my last work day of the week...
[22:24:04] <Casper> working tue-sat have some great advantages actually
[22:24:18] <Casper> on monday... most places are empty
[22:24:44] <Casper> this last monday, I went to see a movie...
[22:24:54] <Casper> ... I was ALONE in the theater!
[22:24:59] <Casper> private display!
[22:55:57] <N1njaneer> Nice!
[22:57:19] <N1njaneer> I went to see The Lion King and Jurassic Park 3D conversions last year. It was just my friend and me and one other guy in the theatre for Jurassic Park.