#avr | Logs for 2015-03-19

Back
[00:08:13] <megal0maniac> twnqx: Now and then
[00:16:43] <Flipp_> aczid: okay, okay, I finally got it. long story short, it's flash vs sram, .init4, .data in SRAM, LDS vs LDI, and some other magic, but I think I got it now :)
[00:20:35] <aczid> oh, so globals go in flash? makes sense
[00:20:52] <aczid> all of sram is for the stack then, in avr?
[00:21:51] <Casper> sram is stack, variables goes in stack
[00:22:19] <Flipp_> aczid: looks like globals are stored in .data in flash
[00:22:23] <Flipp_> but on startup in .init4
[00:22:29] <Flipp_> they're copied in to SRAM
[00:23:19] <Casper> flipp_: afaik, global goes to sram, however the intial value will be stored in flash if defined
[00:23:43] <Casper> unless you use the PROGMEM attribute or something like that, then they become constant in flash
[00:23:47] <Casper> usefull for strings
[00:23:53] <Casper> and LUT
[00:24:24] <Flipp_> Casper: I'm seeing a variable I declare globally
[00:24:30] <Flipp_> become an lds call
[00:24:45] <Flipp_> and following the disassembly
[00:24:54] <Flipp_> the value is stored in flash
[00:25:08] <Casper> I don't use assembly, but flash have a limited write cycle, so it won't write there unless you explicitelly code for it
[00:25:17] <Flipp_> then subsequently copied into SRAM
[00:25:26] <Casper> but the initial condition will be in flash, copied to sram at startup
[00:25:31] <Flipp_> exactly :)
[00:25:32] <Flipp_> yup
[00:25:36] <Flipp_> that's what I just discovered :)
[00:25:54] <Flipp_> ... I've only been doing AVR/microcontroller stuff for like a week
[00:26:19] <Casper> it's good for you to start with assembly, but you'll most likelly move to C very soon
[00:28:19] <Flipp_> Casper: nono, sorry
[00:28:22] <Flipp_> I wrote something in C
[00:28:34] <Flipp_> and I was trying to figure out why it was doing what it was doing
[00:28:42] <Flipp_> so I followed it through the assembly :)
[00:29:18] <Flipp_> I've now got my custom bootloader doin' stuff then jumping into my main program at 0x000
[00:29:23] <Flipp_> small victories, heh
[00:30:53] <Casper> don'T forget to reset the vector table if you did used the bootloader one instead of main one
[00:39:44] <Flipp_> yup yup! got my MCUCR bit for IVSEL switched :)
[00:42:29] <Flipp_> yup yup! got my MCUCR bit for IVSEL switched :)
[01:49:01] <aczid> Flipp_: ah cool
[05:36:24] <skroon> hi
[05:39:51] <skroon> is it possible to use ASF libs from Atmel on non-windows dev environments?
[05:53:25] <Lambda_Aurigae> skroon, probably.
[05:53:39] <Lambda_Aurigae> you will have one heck of a time setting up your environment I bet.
[05:54:08] <Lambda_Aurigae> some of those I've looked at have hard coded windows paths in them which causes all kinds of havoc when going to linux or mac.
[06:27:15] <skroon> Lambda_Aurigae: right, a lot of pain I see :-)
[06:27:28] <skroon> Lambda_Aurigae: i'm already in a lot of pain just trying to get JTAG debugging going on OSX
[06:27:31] <skroon> with avarice
[06:27:43] <Lambda_Aurigae> never used jtag myself.
[06:27:59] <skroon> which really makes me wondering if I should just switch over to Windows in order to be able to do some debugging
[06:28:00] <Lambda_Aurigae> and I find the interface for mac computers to be just,,,,horrendous...but that's just me.
[06:29:44] <Lambda_Aurigae> I just add debugging code to my programs and rely on that.
[06:47:17] <Lambda_Aurigae> oh man...those esp8266 modules are cheap these days.
[06:47:27] <Lambda_Aurigae> under 3 dollars US in some cases.
[06:50:59] <LeoNerd> They're getting silly now
[06:51:05] <Lambda_Aurigae> yeah.
[06:51:25] <Lambda_Aurigae> can't decide whether I want the 8 pin connected version or the 14 pin version.
[06:52:25] <Lambda_Aurigae> can get 10 of them for 30 bucks.
[06:52:52] <Lambda_Aurigae> 30.25 with shipping.
[06:53:13] <LeoNerd> Ah yes, bulk ones. I found a source of nRFs for about £1/each, in larger quantities
[06:53:34] <Lambda_Aurigae> yes. 2.70 each in 10 quantity.
[06:55:18] <Lambda_Aurigae> apparently they have a way to boot the esp8266 from an SD card too rather than the serial flash.
[06:56:47] <twnqx> sd cards are essentilally serial flashs...
[06:56:50] <Lambda_Aurigae> http://www.ebay.com/itm/2-95-EACH-ESP8266-5x-ESP-12-Serial-WIFI-Upgradeable-Arrive-1-10-Biz-Day/271703822004?_trksid=p2054897.c100204.m3164&_trkparms=aid%3D222007%26algo%3DSIC.MBE%26ao%3D1%26asc%3D20140407115239%26meid%3D240864a2c7d04d4c8839520007bc4be1%26pid%3D100204%26rk%3D3%26rkt%3D30%26sd%3D281470224472
[06:56:56] <Lambda_Aurigae> hmm..that didn't paste well.
[06:56:57] <Lambda_Aurigae> oh well.
[06:57:10] <Lambda_Aurigae> 2.95 each for the 14 pin dip type board.
[06:57:14] <Lambda_Aurigae> lots more gpio.
[06:57:23] <Lambda_Aurigae> twnqx, yeah, that they are.
[06:58:47] <Lambda_Aurigae> now to talk the wifey into letting me buy them....muahahahaha.
[07:11:06] <uskerine> I have a couple of Arduino Nano (http://mla-s1-p.mlstatic.com/arduino-nano-30-atmega328p-4144-MLA2653077170_052012-F.jpg) and I would like to start with AVR. I installed AVR Studio (I came here some months ago and some people told me that AVR Studio is so far the only option for single-step debugging in C). I have previous experience with uCs in both ASM and C (8051 mainly) but not with AVR. What
[07:11:06] <uskerine> should I do to start using ArduinoNano with AVRStudio?
[07:18:12] <uskerine> specifically, how can I download code and where could I download a simple blinking led example?
[07:29:15] <Tom_itx> http://tom-itx.no-ip.biz:81/~webpage/how_to/atmega168/mega168_led_blink_delay_index.php
[07:32:45] <uskerine> Tom_itx thanks I am actually following: https://electrosome.com/blinking-led-atmega32-avr-microcontroller/ (pretty similar for a led blinking example)
[07:41:09] <uskerine> so my code is ready, do I have something special to download it to the AVR in the arduino nano?
[07:41:20] <uskerine> I read that they come with some bootloader or something like that
[08:28:55] <skroon> Lambda_Aurigae: add debugging as in printf's you mean right?
[08:45:25] <vicatcu> hi all, i'm writing bootloader code for an atmega1284p, am I in the right place to ask a question about RAMPZ?
[08:45:43] <LeoNerd> Seems as good a place as any
[08:46:36] <vicatcu> heh
[08:47:50] <vicatcu> it seems clear to me from the datasheet (and from reading optiboot source) that when I want to start writing pages where the byte address is above 64k, i have to do something with RAMPZ
[08:48:00] <vicatcu> it's not super clear to me what though
[08:48:21] <vicatcu> can anyone give me insight or point me at a reference that makes that clear
[09:06:45] <uskerine> http://www.jayconsystems.com/tutorial/atmerpt1/
[09:12:22] <vicatcu> hm... thought there'd be more action here
[09:12:56] <uskerine> hi
[09:13:10] <uskerine> I have followed about tutorial on how to setup avrdude with Atmel Studio
[09:13:59] <uskerine> I got the dos screen when clicking on "Serial Programmer" (the configured external avrdude tool) but the screen disappears immediatelly, how can I see which error I am getting?
[09:19:44] <uskerine> got it. I used "Use Output Windows" checkbox while configuring the external tool
[09:26:40] <uskerine> is WDT disabled by default on reset in AVR?
[09:26:53] <vicatcu> depends on fuses
[09:27:09] <vicatcu> some avrs have a fuse for "WDT always enabled"
[09:27:28] <uskerine> when is that defined
[09:27:37] <uskerine> and how can I check?
[09:30:45] <vicatcu> avr studio should let you check
[09:30:54] <vicatcu> when you connect the programmer and choose the device
[09:32:14] <vicatcu> or look at the datasheet for your device is another way
[09:41:04] <uskerine> so when you say that some avrs have a fuse for "WDT always enabled" it actually means that it depends on the specific device, right?
[09:41:22] <uskerine> so for ATMega328P it will have it disabled or enabled, and for other AVR it might be different
[09:41:57] <uskerine> I don't see it so obvious for checking it with atmel studio
[09:42:36] <uskerine> I am using avrdude external tool for downloading code as I am using Arduino Nano hardware (not sure if that is the right approach)
[09:56:01] <Shavik> In a RS-485 network, if all the devices have termination resistors (100 Ohm resistors between the A & B lines, CAT5E) would this cause communications issues?
[09:56:31] <LeoNerd> 100 sounds low for 485.. but its' a while since I remember playing with it
[09:56:34] <LeoNerd> I thought ~120
[10:02:22] <skroon> is avr-gcc build from the same source as gcc ?
[10:02:31] <RattusRattus> you only terminate the ends of the bus not each node
[10:02:40] <Shavik> Well its not exactly a end to end bus
[10:02:42] <Shavik> more of a star
[10:02:48] <Shavik> And we have devices that work with two types of networks
[10:02:56] <LeoNerd> Oh.. yeah.
[10:03:00] <RattusRattus> that is far from ideal
[10:03:02] <LeoNerd> Definitely don't put terminators in the middle nodes
[10:03:15] <Shavik> So what I'm seeing is that slaves on the network, it works fine. I plug in a 3rd node and all hell breaks loose
[10:03:42] <Shavik> 2 slaves. works fine*
[10:04:01] <RattusRattus> impeadance control of the star topology is going to rat shit.
[10:04:15] <LeoNerd> Yah; 485 is supposed to be a linear bus
[10:05:20] <RattusRattus> you may want to re-consider the topology or use a 'hub' to seporate the star into several bridged spurs
[10:05:26] <skroon> i'm trying to use avarice to debug something, but whenever when i'm in avr-gdb and type "list" i'm getting an error that it can't find "libgcc/config/avr/lib1funcs.S: No such file or directory."
[10:05:34] <skroon> i've recompiled avarice, and avr-gdb
[10:05:46] <skroon> but still getting these issues, i'm kind of lost where this messages is coming from
[10:05:46] <Shavik> RattusRattus, I should mention that we have a central hub with 3-5 ports. each port could be a linear run of devices
[10:05:48] <skroon> anyone have a clue?
[10:06:09] <RattusRattus> skroon: sorry /me can't help
[10:06:20] <Shavik> I guess that would be a hub and spoke not star :/
[10:06:42] <RattusRattus> Shavik: so the hub is active?
[10:07:01] <RattusRattus> or is this just a passive connector block?
[10:07:05] <Shavik> The hub breaks out our 485 from our linux control (single port) to multiple ports
[10:07:16] <Shavik> The hub also injects our power for our remote devices
[10:07:24] <Shavik> But the 485 portion is merely passive
[10:07:34] <RattusRattus> yep and that is the problem :-(
[10:07:46] <Shavik> Hmm
[10:08:05] <Shavik> Lower baud rates help?
[10:08:07] <RattusRattus> as long as you only have two ports connected I assume everything is fine
[10:08:20] <Shavik> I have run this system with a single linear string of around 5-6 devices
[10:08:26] <Shavik> Just these new devices all have terminators
[10:08:30] <Shavik> Hadn't used that setup before
[10:09:52] <RattusRattus> Shavik: remove the terminators from all but the end two nodes and re-structure the network into a string
[10:10:28] <Shavik> Say each setup is variable in terms of what the "end devices" could be
[10:10:30] <Shavik> Thoughts on that?
[10:10:41] <Shavik> Would it be wise to just make some "terminators"?
[10:10:45] <Shavik> Each device has 2 jacks. for passthrough
[10:10:51] <Shavik> So they can be stringed
[10:11:21] <RattusRattus> thats pretty much the way it should be!
[10:11:42] <Shavik> Yea Just the room configuration a single string isn't optimal :/
[10:11:43] <RattusRattus> you should also calculate the number of 'loads'
[10:12:31] <RattusRattus> sorry to say it but if you insist on a star topollogy why have you picked a physical layer that doesn't match?
[10:12:50] <Shavik> Well I have to say, the topology was changed a bit later in the design
[10:12:53] <Shavik> Not 100% my idea
[10:13:00] * RattusRattus grins
[10:13:03] <Shavik> You know how the salesmen and executives get
[10:13:08] <Shavik> :/
[10:13:09] <RattusRattus> ack.
[10:14:05] <Shavik> Really appreciate the insight
[10:14:34] * RattusRattus jsut found the wikipeidia entry on it. actully the topology wording is far better than I have been able to describe it... (warning long paste)
[10:14:54] <RattusRattus> The recommended arrangement of the wires is as a connected series of point-to-point (multidropped) nodes, i.e. a line or bus, not a star, ring, or multiply connected network. Ideally, the two ends of the cable will have a termination resistor connected across the two wires. Without termination resistors, reflections of fast driver edges can cause multiple data edges that can cause data corruption. Termination resistors also reduce electrical ...
[10:15:00] <RattusRattus> ... noise sensitivity due to the lower impedance, and bias resistors (see below) are required. The value of each termination resistor should be equal to the cable characteristic impedance (typically, 120 ohms for twisted pairs).
[10:15:04] <RattusRattus> Star and ring topologies are not recommended because of signal reflections or excessively low or high termination impedance. If a star configuration is unavoidable, special RS-485 star/hub repeaters are available which bidirectionally listen for data on each span and then retransmit the data onto all other spans.
[10:15:22] <RattusRattus> far better than I have been able to describe it :-)
[10:15:55] <Shavik> So there is the active hub y ou mention
[10:16:08] <Shavik> Seems you'd have issues with flow control on the retransmission?
[10:16:18] <RattusRattus> yes and no
[10:16:29] <RattusRattus> it is all down to timing
[10:16:35] <Shavik> all about your protocol
[10:16:40] <Shavik> master asks out, it gets repeated
[10:16:41] <Shavik> etc
[10:16:44] <Shavik> I get it
[10:17:26] <RattusRattus> provided that your cable lengths + any buffering dime in the repeater mean that signalling reaches *all* nodes withing the maximum period all is good
[10:18:03] <Shavik> Well
[10:18:05] <RattusRattus> remember speed of light in cable is about 0.7C so you can calculate all of that
[10:18:16] <Shavik> Yea, fairly short runs. the whole 485 system is contained with a single room
[10:18:20] <Shavik> so no cable > 30 ft
[10:18:38] <Shavik> Currently running at 38400 baud
[10:19:14] <RattusRattus> then a repeater may be a valid solution. but given that sort of size a multidrop line sounds more optimal
[10:19:32] <LeoNerd> 485 is quite capable of running a lot faster than that. DMX-512 uses 485 at 250kBaud
[10:19:39] <LeoNerd> Very specifically in a linear arrangement though :)
[10:20:08] <RattusRattus> LeoNerd: ack. DMX hacking is where I remember all this from :-)
[10:20:30] <LeoNerd> If you ever want a non-linear DMX arrangement, you need the active repeater/hub thing in the middle
[10:20:40] <Shavik> See, we're in super fast go mode :/ (you know) and we just designed and made a passive hub / power supply board thats around $7k for the 20 protos or whatever
[10:20:43] <Shavik> :)
[10:20:47] <Shavik> wheee not my money
[10:20:59] <Shavik> I'd rather bad news than be clueless though
[10:21:20] <RattusRattus> thats ok. just connect in and out and ignoore the other 'ports'
[10:21:27] <Shavik> True
[10:21:48] <Shavik> I guess worst case, this first version has a lot more cable since we string it all together
[10:22:03] <RattusRattus> I assume the 'hub' includes the line pull up
[10:22:15] <RattusRattus> got to go...
[10:22:22] <Shavik> That may have been an omission but we can add those in by hand on the protos
[10:22:26] <Shavik> ok. thanks for all help
[10:33:04] <Tekkkz> Hello, hi Lambda_Aurigae ; you remeber me?
[10:44:54] <Shavik> RattusRattus, Just when you get around to reading this. I removed a termination resistor from the 3rd slave node, communications have returned too 100% successful.
[10:47:08] <RattusRattus> Shavik: good news. it is common to include terminators in a "plug" that stops you adding further devices on the chain. but also common to have a switch to turn termination on or off on each node
[10:47:40] <Shavik> The switch is an interesting thought. Thank you
[10:47:45] <Shavik> little dip switch or something
[10:48:05] <LeoNerd> I prefer the safety of that plug
[10:48:17] <LeoNerd> It's what DMX uses. You physically cannot accidentally leave a terminator in the middle of a chain
[10:48:24] <Shavik> This system will be maintained by "not so trained" techs
[10:48:29] <Shavik> so maybe a plug would be a good idea
[10:48:36] <LeoNerd> There's only one "out" socket - either it chains out to another fixture, or it has a terminator
[10:48:43] <Shavik> could embed a resistor in an RJ45 jack
[10:48:51] <Shavik> well plug
[10:48:56] <LeoNerd> You can ofcourse still forget to put one in, but again that's visually obvious due to a lack of anything plugged in... the OUT socket looks "wrong"
[10:49:23] <RattusRattus> I don't like the switch personnaly - it adds cost to each and every node (the switch is more expensive than the resistor!) and people often extend the network / string and forget to set the terminaton switches (often therfore having more terminators than required and in the wrong place)
[10:50:30] * RattusRattus reads above and finds everyone else has the same thoughts on the switch as he does :-)
[10:51:55] <Shavik> very good points all around
[10:52:01] <Shavik> LeoNerd. I really like the plug idea
[10:52:05] <Shavik> Allows for easy expansion
[10:57:45] <Tekkkz> can anyone help me?
[10:58:10] <Tekkkz> http://forums.adafruit.com/viewtopic.php?f=19&t=70454&p=357412
[11:01:46] <Tekkkz> why is the ISR not generated on the pin?
[11:01:56] <RattusRattus> Tekkkz: /me is confused. what the adafruit guy is asking you to do appears sane.
[11:02:23] <Tekkkz> no man
[11:02:41] <Tekkkz> this adafruit guy is as useless as fuck *sorry for verbal
[11:02:54] <Tekkkz> i have the pin F0
[11:02:57] <Tekkkz> i toggle F0
[11:03:03] <Tekkkz> and my program dont work
[11:03:07] <RattusRattus> so if you don't have your custom define for PD6 and instead toggle a differant IO pin does the same problem still occur?
[11:03:41] <malinus> Don't expect people to help you, when you post 1/3 of your code
[11:03:53] <Shavik> And call others that tried, "useless as fuck"
[11:04:11] <Tekkkz> wait, so you mean i just should PORTF ^= (1<<PF0) ?? i posted everything
[11:05:13] <Tekkkz> btw
[11:05:32] <RattusRattus> ok lets go to the very beginning - assume I am a dumb ass fuck :-) what are you trying to achive (no code here, just what do you want to happen)
[11:05:42] <Tekkkz> if i dont use thier bootloader and flash my programm with isp, there is still a problem at the frequency: it should be 3.2kHz
[11:05:45] <Tekkkz> look the graph:
[11:06:06] <Tekkkz> http://i.imgur.com/jNYMIHa.png
[11:06:12] <Tekkkz> isnt square
[11:06:17] <Tekkkz> and not 3.2kHz
[11:06:58] <Tekkkz> why is it so wrong?
[11:07:22] <Tekkkz> wait
[11:07:24] <Tekkkz> okay
[11:07:34] * RattusRattus restates - forget what you have for the moment. please tell me what you are wnating to happen
[11:07:41] <RattusRattus> wanting
[11:08:03] <Tekkkz> RattusRattus: lets first make my programm running normal and then focus on running with bootloader ok?
[11:08:16] <Tekkkz> so, i explain my "project" now?
[11:08:19] * RattusRattus gives up
[11:08:25] <Tekkkz> its ok
[11:08:26] <Tekkkz> wait
[11:08:37] <RattusRattus> you don't want help
[11:08:54] <Tekkkz> i want!!! > i want to generate a 3.2kHz square wave
[11:08:55] <Tekkkz> its all
[11:09:04] <RattusRattus> you want magic to happen and your code to just work. we have no idea what you think work is
[11:09:10] <Tekkkz> okay
[11:09:16] <Tekkkz> ill upload my whole project
[11:09:20] <RattusRattus> no
[11:09:27] <Tekkkz> ?
[11:09:43] <RattusRattus> so all you want to happen is you toggle a pin at 3.2kHz
[11:09:47] <RattusRattus> nothing else?
[11:09:48] <Tekkkz> yep
[11:10:01] <RattusRattus> ok and what do you have connected to that pin?
[11:10:28] <Tekkkz> actually my oscilloscope
[11:10:47] <RattusRattus> anything else connected?
[11:10:52] <Tekkkz> no
[11:10:54] <RattusRattus> ok
[11:11:19] <RattusRattus> does it have to be that pin i.e. can we move to another pin for TEST)
[11:11:29] <Tekkkz> we can move any pin you want
[11:11:37] <RattusRattus> good
[11:11:46] <Tekkkz> you dont like F0?
[11:12:55] <RattusRattus> no not at all. but you appeared to be implying that the lack of square wave could be indicating a hardware problem
[11:13:13] <RattusRattus> so we move pin and see if the problem follows to the new pin
[11:13:29] <Tekkkz> okay, which pin do you recommend?
[11:13:52] <RattusRattus> if it doesn't then you are likley right if the fault moves to the new pin then it is somthing else
[11:14:06] <RattusRattus> doesn't matter any other pin
[11:14:08] <Tekkkz> okay, what with F7?
[11:14:19] <RattusRattus> sure
[11:14:53] <Tekkkz> still not exat square, still the raising edge
[11:15:07] <RattusRattus> ok
[11:16:02] <zerowidth> is there a physical limit to how quickly that edge can rise? e.g. capacitance in the wires or breadboard or whatever, plus limitations of what the microcontroller can do?
[11:16:36] <RattusRattus> so if you change your code (testing only at this stage) to set as a GPIO output, then portf ^= portf & 0x40
[11:16:44] <RattusRattus> as an endless loop
[11:16:52] <twnqx> mh?
[11:17:06] <twnqx> did you mean portf ^= 0x40 ?
[11:17:19] <RattusRattus> yes sorry!
[11:17:37] <RattusRattus> i.e. no isr, just burn cpu cycles :-)
[11:17:47] <twnqx> and sleep afterwards :P
[11:18:03] <RattusRattus> no sleep at this stage! as fast as the mcu will go
[11:18:21] <Tekkkz> so you want me to jsut make it high?
[11:18:28] <Tekkkz> and then nothing, just turn it on?
[11:18:49] <RattusRattus> no toggle state high / low
[11:19:01] <RattusRattus> thats what the xor function is doing
[11:19:44] <Tekkkz> ahh, you mean portf ^= 0x40 at the isr?
[11:19:54] <RattusRattus> hang on
[11:21:25] <RattusRattus> int main(void){
[11:21:25] <RattusRattus> DDRF = 0xFF; // make port output
[11:21:25] <RattusRattus>
[11:21:25] <RattusRattus> while(1){
[11:21:25] <RattusRattus> PORTF ^= 0x40; // toggle bit 7
[11:21:28] <RattusRattus> }
[11:21:30] <RattusRattus> return 0;
[11:21:45] <RattusRattus> no isr at all
[11:21:56] <RattusRattus> just change the state of f.7
[11:22:36] <Tekkkz> okay
[11:22:39] <Tekkkz> btw
[11:22:43] <Tekkkz> without hte isr the code works
[11:22:46] <Tekkkz> at the bootloader
[11:22:49] <Tekkkz> just
[11:22:53] <Tekkkz> commended it out
[11:22:55] <Tekkkz> ant it works
[11:25:41] <Tekkkz> okay
[11:25:44] <Tekkkz> i tested your code
[11:25:54] <Tekkkz> and it seems to be a square
[11:26:06] <Tekkkz> ofc its verry fast and so it seems to be, im not 100& sure
[11:26:15] <Tekkkz> mhh
[11:26:23] <RattusRattus> ok so that tells us there is no hardware problem
[11:26:27] <Tekkkz> shouldnt this be as fast as the CLK?
[11:26:46] <RattusRattus> yes and no.
[11:27:05] <Tekkkz> im running 16mhz
[11:27:10] <Tekkkz> but its just 1.6mhz
[11:27:21] <RattusRattus> it is as fast as the clock, but your c code is not just 1 line of machine code
[11:27:40] <Tekkkz> but it should be more than 1.6mhz
[11:28:08] <Tekkkz> hm
[11:28:16] <RattusRattus> you have a loop that needs to be tested, and then each itteration of the loop you only change the state so in fact it will be overhead of loop * 0.5 clock
[11:28:37] <Tekkkz> so it is possible tahts just 1.6mhz?
[11:28:52] <Tekkkz> no
[11:28:59] <RattusRattus> then you have the fact that the IO port can not run at 100% clock (it blocks)
[11:29:08] <Tekkkz> oh ok
[11:29:14] <Tekkkz> yes, then 1.6mhz is ok
[11:29:25] <Tekkkz> you wanna see a pic of the wave?
[11:30:14] <RattusRattus> but the fact that you see a nearly (it is impossable to achive a perfect) square wave tells us this is not a hardware problem so it must be how you are trying to genorate the waveform
[11:30:49] <Tekkkz> wait a mment
[11:31:06] <RattusRattus> no need for a pic - I can see what your problem is but need to take you on the jurney so that you understand the problem and can see how to fix it the NEXT time you have such a problem
[11:31:12] <Tekkkz> http://i.imgur.com/EpFwzPV.png
[11:31:28] <Tekkkz> it looks ok, the little not-good stuff is possible from the jumper cables
[11:31:46] <RattusRattus> that looks pretty good to me!
[11:32:00] <Tekkkz> nice
[11:32:11] <Tekkkz> so now we need to have a look at the timer-based generation?
[11:32:14] <RattusRattus> you can see the rise time and fall time are about the same period.
[11:32:36] <RattusRattus> and you can see some 'ringing on both rising and falling edges
[11:32:39] <RattusRattus> so good.
[11:32:45] <RattusRattus> ok lets now look at the code
[11:33:11] <Tekkkz> wait
[11:33:17] <Tekkkz> i need to go away for ca 5 mins
[11:33:20] <RattusRattus> so first of all what do you think your should do.
[11:42:04] <Tekkkz> okay im back
[11:42:10] <Tekkkz> so waht i would do now, right?
[11:46:37] <Tekkkz> ok
[11:46:45] <Tekkkz> i would configure the timer
[11:46:50] <Tekkkz> in ctc mode
[11:47:06] <Tekkkz> and with presc. and counter so, taht it will generate 3.2khz
[11:47:35] <Tekkkz> with the formula: frequ=(F_CPU)/(2*PRE*(COUNTER+1))
[11:47:49] <Tekkkz> RattusRattus: right?
[11:54:26] <Tekkkz> RattusRattus: so first init_timer
[11:54:33] <Tekkkz> PCNT0 = 0
[11:54:37] <Tekkkz> *TCNT
[11:55:02] <Tekkkz> then activate ISR INT : TIMSK0 = _BV(OCIE0A)
[11:55:21] <Tekkkz> CTC Mode: TCCR0A = _BV(WGM01)
[11:55:49] <Tekkkz> PRESCLAER 8: TCCR0B = _BV(CS01) | _BV(CS00)
[11:56:05] <Tekkkz> then count up to 38: OCR0A = 38
[11:56:15] <Tekkkz> and enable interrupts now : sei()
[11:56:18] <Tekkkz> RattusRattus: all right?
[12:14:40] <RattusRattus> sorry moved location (home from work)
[12:15:32] <RattusRattus> no my question was what is the ISR doing? not how are you configureing the timer :-)
[12:16:57] <RattusRattus> absolutly
[12:18:15] <RattusRattus> i.e. what do you think TOGGLE(TIMER0_OC0B); is there to do?
[12:19:15] <RattusRattus> don't forget that is really - TIMER0_OC0B ^= TIMER0_OC0B
[12:22:15] <Tekkkz> he?
[12:23:04] <RattusRattus> when an intterupt from the timmer happens you toggle the state of TIMER0_OC0B.
[12:24:19] <Tekkkz> yes
[12:24:24] <Tekkkz> nono
[12:24:25] <RattusRattus> this if it was 0b00100100 before the interrupt it would be 0b11011011 afterwards. that is clearly plain wrong. what did you WANT to happen
[12:24:28] <Tekkkz> my toggle is sth different
[12:24:34] <Tekkkz> nono
[12:24:53] <Tekkkz> http://ix.io/gYJ
[12:25:11] <Tekkkz> checkout toggle definition
[12:25:45] <RattusRattus> yes so the line TOGGLE(TIMER0_OC0B); expands into TIMER0_OC0B ^= TIMER0_OC0B
[12:26:19] <RattusRattus> which performs an xor on the value of TIMER0_OC0B.
[12:26:21] <Tekkkz> no
[12:26:24] <Tekkkz> nonono
[12:26:31] <Tekkkz> it toggles directly the port
[12:26:37] <Tekkkz> not the timer0_ocb0
[12:26:52] <Tekkkz> its a gpio function
[12:27:07] <RattusRattus> TIMER0_OC0B is not a port!
[12:27:16] <Tekkkz> wrong
[12:27:26] <Tekkkz> define TIMER0_OC0B D,2
[12:27:47] <Tekkkz> *i mean pin
[12:28:03] <Tekkkz> toggle(..) toggles the PD2 of PORTD
[12:28:10] <RattusRattus> so humor me here replace that toggle call with PORTF ^= 0x40; instead
[12:28:23] <Tekkkz> not necessary
[12:28:28] <Tekkkz> thats what TOGGLE(..) does
[12:28:38] <Tekkkz> see define TIMER0_OC0B D,2
[12:28:40] <Tekkkz> *see
[12:28:46] <Tekkkz> http://ix.io/gYJ
[12:28:48] <RattusRattus> please just do it for me
[12:29:13] <Tekkkz> okay
[12:30:07] <Tekkkz> its for pf7?
[12:30:23] <Tekkkz> ill cahnge it to pd2
[12:30:34] <RattusRattus> well we had port F.7 being used in the test code earlier....
[12:30:41] <RattusRattus> please keep it F.7
[12:31:11] <RattusRattus> i.e. not assocated with timer0 in any way
[12:31:41] <Tekkkz> okay
[12:33:09] <Tekkkz> dont work, wait
[12:33:16] <Tekkkz> is 0x40 for 7??
[12:33:42] <Tekkkz> no
[12:34:00] <RattusRattus> indeed should have been 0x80 but earlier you didn't spot that
[12:34:23] <Tekkkz> okay
[12:35:05] <Tekkkz> output the same like with TOGGLE(..) ofc, its the same as macro .. but you wont accept using makros ;) and now there is a falling round edge, not the raising one
[12:35:15] <RattusRattus> so if we stick with 0x40 it should be bit 6 (and your scope should be already on that line)
[12:35:30] <Tekkkz> i put it on F7 now
[12:36:10] <RattusRattus> no I don't trust mackros that call macros to always work the way I think they will
[12:36:37] <Tekkkz> yes ok, but this macro is ok
[12:37:06] <Tekkkz> wait
[12:37:12] <RattusRattus> so what line was going up and down?
[12:37:35] <RattusRattus> D2 or F7/6?
[12:37:43] <RattusRattus> or both?
[12:37:44] <Tekkkz> http://i.imgur.com/2M9LuXO.png
[12:37:45] <Tekkkz> F7
[12:37:48] <Tekkkz> D2
[12:37:51] <Tekkkz> F6
[12:37:53] <Tekkkz> every
[12:37:59] <Tekkkz> but only like the image i sent
[12:38:07] <Tekkkz> can we take it as square?
[12:38:26] <RattusRattus> yep thats square
[12:38:31] <Tekkkz> okay
[12:38:36] <Tekkkz> but its 500hz
[12:38:39] <Tekkkz> hmm
[12:38:43] <Tekkkz> let me calculate
[12:39:07] <Tekkkz> f=16000000/(2*8*39)
[12:40:21] <Tekkkz> uhh
[12:40:25] <Tekkkz> its 64, not 8
[12:40:45] <Tekkkz> => 3205.128205128205 hz
[12:40:53] <Tekkkz> but my osc shows 500hz
[12:41:00] <Tekkkz> so
[12:41:20] <Tekkkz> the clock isnt running on 16mhtz i think
[12:41:27] <RattusRattus> could be
[12:41:51] <Tekkkz> 500*(2*64*39)
[12:41:57] <Tekkkz> 2496000
[12:41:59] <Tekkkz> 2.5mhz
[12:42:01] <Tekkkz> hm
[12:42:02] <RattusRattus> so using ISP? check the control flags (is clk/8 set?)
[12:42:18] <Tekkkz> ho?? where?
[12:42:41] <Tekkkz> w8
[12:42:44] <Tekkkz> Fuses OK (E:C3, H:D0, L:FC)
[12:42:46] <Tekkkz> fuses
[12:42:47] <Tekkkz> !!
[12:43:10] <RattusRattus> fuses yes (sorry not controil flags)
[12:43:35] <Lambda_Aurigae> same smell different flower
[12:43:56] <Tekkkz> think the fuses arent correct, can you help me check them please, i never set fuses before
[12:44:10] <Tekkkz> http://www.engbedded.com/fusecalc/
[12:44:24] <Lambda_Aurigae> should call them breakers instead of fuses these days...fuses is from the day when they were settable once by blowing actual fuses out.
[12:45:05] <LeoNerd> 'config'
[12:45:18] <RattusRattus> ack, but even back then it was EPROM (OTP just not having the glass window for UV erase)
[12:45:39] <RattusRattus> Tekkkz: ok so which device are you using?
[12:45:45] <Tekkkz> atmega32u4
[12:47:05] <RattusRattus> so clkdiv8 is clear good
[12:47:41] <RattusRattus> you could try setting CKOUT and scoping it!
[12:48:02] <Tekkkz> what's doing?
[12:48:35] <RattusRattus> no
[12:48:37] <RattusRattus> eek
[12:48:57] <RattusRattus> E:C3 H:D0 L:FC is wrong
[12:49:49] <Tekkkz> whats wrong?
[12:50:12] <RattusRattus> that is for having an external crystal between 3 and 8MHz
[12:50:23] <Tekkkz> uhh
[12:50:25] <Tekkkz> wow
[12:50:27] <Tekkkz> fuck adafruit
[12:50:31] <Tekkkz> what are they doing?
[12:50:32] <RattusRattus> you told me you have a 16MHz clock
[12:50:36] <Tekkkz> i have
[12:50:42] <Tekkkz> *crystal
[12:50:48] <Tekkkz> 16mhz
[12:51:44] <RattusRattus> make it L:FE instead
[12:52:14] <RattusRattus> no L:FF is better
[12:53:22] <Tekkkz> okay and lockbit?
[12:53:48] <RattusRattus> leave the lock bits - they are only to stop people changing the code
[12:55:10] <Tekkkz> the lockbit is set by adafruit
[12:55:27] <Tekkkz> -U lock:w:0x2F:m
[12:55:40] <RattusRattus> ok leave it be
[12:55:52] <Tekkkz> what does 2F do?
[12:56:12] <RattusRattus> as long as you can program via isp and set fuse bits we don't care
[12:56:18] <Tekkkz> okay
[12:56:23] <Tekkkz> so i set the fuse bits now
[12:56:30] <Tekkkz> Fuses OK (E:C3, H:D0, L:FF)
[12:56:38] <Tekkkz> and now?
[12:56:53] <RattusRattus> look at your output on F.7
[12:56:58] <RattusRattus> has it changed?
[12:57:18] <Tekkkz> looooooooooo
[12:57:20] <Tekkkz> oooooooo
[12:57:23] <Tekkkz> l
[12:57:24] <Tekkkz> problem:
[12:57:28] <Tekkkz> no, it doesnt
[12:57:29] <Tekkkz> but
[12:57:51] <Tekkkz> if im changing OCR0A = 38 to OCR0A = 76
[12:58:00] <Tekkkz> nothing changes at the frequency
[12:58:13] <RattusRattus> ok. that sounds wrong
[12:58:18] <Tekkkz> yes
[12:58:56] <RattusRattus> need to look on real hardware - that will have to wait til i have an avr in front of me. can take a look tomorrow...
[12:59:32] <Tekkkz> hm wait
[12:59:42] <Tekkkz> are you sure you selected the right crystal at ffusecalc?
[12:59:44] * RattusRattus should have a mega32 about the place, cirtainly i have others!
[13:00:44] <RattusRattus> selected external crystal >= 8MHz with longest start up time possibe (16k clk cycles + 65ms)
[13:01:24] <RattusRattus> bb soon - collecting wife
[13:01:51] <Tekkkz> haha
[13:04:39] <Tekkkz> uhh lol
[13:04:43] <Tekkkz> avrdude: verifying ...
[13:04:45] <Tekkkz> avrdude: verification error, first mismatch at byte 0x0000
[13:04:47] <Tekkkz> 0xc3 != 0xf3
[13:04:49] <Tekkkz> avrdude: verification error; content mismatch
[13:04:51] <Tekkkz> avrdude: safemode: efuse changed! Was f3, and is now c3
[13:04:52] <Tekkkz> Would you like this fuse to be changed back? [y/n]y
[13:04:54] <Tekkkz> is it protected by the lockbits?
[13:05:49] <Tekkkz> * Note that some numerical values refer to fuses containing undefined bits (set to '1' here). Depending on the target device these fuse bits will be read either as '0' or '1'. Verification errors will occur if the values are read back with undefined bits set to '0'. Everything is fine if the values read from the device are either the same as programmed, or the following values (undefined set to '0'): Extended:
[13:05:52] <Tekkkz> 0x03.
[13:05:56] <Tekkkz> ??
[13:18:03] <RattusRattus> ok back
[13:19:32] <RattusRattus> so yep thats the fuse calc tool. set extended to 0x0
[13:19:40] <RattusRattus> 0x0f even!
[13:23:36] <Tekkkz> hä? so how should i set the fuses now?
[13:24:20] <Tekkkz> and are you sure that it is Ext. Crystal Osc.; Frequency 8.0- MHz; Start-up time: 16K CK + 65 ms; [CKSEL=1111 SUT=11] right?
[13:24:34] <Tekkkz> is it a crystal osc and not a low frequ crystal?
[13:25:20] <RattusRattus> 16MHz in AVR terms is not low frequancy!
[13:25:39] <Tekkkz> okay
[13:25:42] <Tekkkz> so what fuse bits?
[13:25:58] <RattusRattus> look at the options for clock.
[13:26:18] <RattusRattus> you have told me its a 16MHz xtal
[13:26:26] <Tekkkz> yup
[13:26:38] <RattusRattus> so that means it is an external crystal oscilator
[13:27:02] <RattusRattus> it is greater than 8MHz so 8Mhz- option needs to be selected as well
[13:27:39] <Tekkkz> okay
[13:28:05] <RattusRattus> and finally we really don't care how long it takse for the crystal clock to stabalise so we will leave it for as longt as possible hence 16000 clock cycles and 65mS before the AVR comes out of reset
[13:28:07] <Tekkkz> -U lfuse:w:0xff:m -U hfuse:w:0xd9:m -U efuse:w:0xf3:m ?
[13:28:25] <RattusRattus> no
[13:28:35] <RattusRattus> -U lfuse:w:0xff:m -U hfuse:w:0xd9:m -U efuse:w:0x03:m
[13:28:51] <RattusRattus> just checking h and l
[13:29:06] <Tekkkz> why 03?
[13:29:28] <Tekkkz> fuck, i can set extended:
[13:29:30] <Tekkkz> avrdude: verifying ...
[13:29:33] <Tekkkz> avrdude: verification error, first mismatch at byte 0x0000
[13:29:35] <Tekkkz> 0xc3 != 0x03
[13:29:37] <Tekkkz> avrdude: verification error; content mismatch
[13:29:39] <Tekkkz> avrdude: safemode: efuse changed! Was 3, and is now c3
[13:30:05] <RattusRattus> yep the high nibble is undefined...
[13:30:14] <RattusRattus> hell we don't need to change it
[13:30:16] <RattusRattus> try
[13:30:24] <RattusRattus> -U lfuse:w:0xff:m -U hfuse:w:0xd9:m only
[13:30:36] <RattusRattus> but just checking 0xd9
[13:31:35] <Tekkkz> Fuses OK (E:C3, H:D9, L:FF)
[13:31:36] <Tekkkz> okay
[13:31:38] <Tekkkz> btw
[13:31:41] <Tekkkz> i found something out
[13:31:58] <Tekkkz> i said that my frequ is all the time 500hz but it should be sth different
[13:32:05] <Tekkkz> i found out why it is 500hz
[13:32:18] <Tekkkz> cause it doesnt count up to my value, it counts to 0xff
[13:32:22] <Tekkkz> the full count
[13:32:35] <Tekkkz> (16000000)/(2*64*256)=488.28125
[13:32:50] <RattusRattus> ahhh!
[13:32:58] <RattusRattus> that would be it
[13:33:08] <Tekkkz> but why?
[13:34:17] <RattusRattus> well timer 0 is an 8bit timer so if your full value is greater than 0xff then it can't count that far!
[13:34:45] <Tekkkz> http://ix.io/gYT
[13:34:48] <Tekkkz> it isnt
[13:35:08] <RattusRattus> ok
[13:35:19] <RattusRattus> so what did you mean by
[13:35:36] <Tekkkz> by?
[13:35:41] <RattusRattus> cause it doesnt count up to my value, it counts to 0xff
[13:37:10] <Tekkkz> yes
[13:37:13] <Tekkkz> look
[13:37:23] <Tekkkz> my value is 38
[13:37:30] <Tekkkz> at calculation you need my_val+1
[13:37:33] <Tekkkz> so:
[13:37:37] <RattusRattus> ack
[13:37:45] <RattusRattus> ok now see what you mean
[13:37:54] <Tekkkz> (16000000)/(2*64*39)=3205.128205128205
[13:37:57] <RattusRattus> you are saying that it compleatly ignoors your value
[13:38:13] <Tekkkz> but if i have my value 0xff its generating 500hz, and thats what is is doing with every val
[13:38:17] <Tekkkz> yep
[13:40:45] <Tekkkz> you have an idea/solution, maybe we need to have a look at timer configuration in datasheet?
[13:42:12] * RattusRattus needs to sit down with an avr in front of him. it has been too long
[13:42:17] <RattusRattus> will do that in the morning
[13:42:45] <Tekkkz> okay, but tomorrow im not online before 13:30 GMT+1
[13:44:22] <RattusRattus> np will have it sorted by then (I hope!)
[13:44:43] <Tekkkz> okay, nice, btw, from where are you?
[13:47:54] <RattusRattus> uk
[13:48:05] <RattusRattus> GMT
[13:48:09] <Tekkkz> ok
[13:48:13] <Tekkkz> yeah, me german
[13:48:33] <Tekkkz> 19:27:15
[13:51:43] <Tekkkz> RattusRattus: http://www.atmel.com/Images/Atmel-7766-8-bit-AVR-ATmega16U4-32U4_Datasheet.pdf#page=90&zoom=auto,-201,666 read the paragraph under the figure13-5
[13:51:56] <Tekkkz> maybe it explains the 0xff cout up
[13:54:27] <RattusRattus> http://www.avrfreaks.net/forum/tut-c-newbies-guide-avr-timers?name=PNphpBB2&file=viewtopic&t=50106
[13:58:13] <Laurenceb> hi, can anyone help?
[13:58:15] <Laurenceb> in temp3, MCUCR
[13:58:15] <Laurenceb> sbi temp3, 7
[13:58:15] <Laurenceb> out MCUCR, temp3
[13:58:22] <Laurenceb> ^why wont this asm build??
[13:58:36] <Tekkkz> whats temp3?
[13:58:39] <Tekkkz> whats the error?
[13:59:35] <Laurenceb> afro.asm(2850) : Error : I/O out of range (0 <= P <= 31)
[13:59:56] <Laurenceb> the middle line
[14:00:02] <Tekkkz> im eating now, sry
[14:00:42] <Flipp__> what is temp3
[14:01:01] <Laurenceb> a variable
[14:01:10] <Flipp__> apparently temp3 is assigned to a register that's >31
[14:01:25] <Laurenceb> hmmm
[14:01:30] <Laurenceb> might be feasible
[14:01:47] <RikusW> sbi works directly on IO not registers
[14:01:54] <Laurenceb> no
[14:01:56] <Laurenceb> def temp3 = r22 ; main temporary (L)
[14:02:00] <Laurenceb> oh right
[14:02:03] <Flipp__> I'm just pulling it from http://www.avrfreaks.net/forum/avra-io-out-range-problem
[14:02:07] <RikusW> Set Bit IO
[14:02:19] <RikusW> use ori temp3,0x80
[14:02:21] <Laurenceb> sbi MCUCR, 7 fails with same error
[14:02:25] <RikusW> or (1<<7)
[14:02:43] <Laurenceb> ori = or in place?
[14:02:49] <RikusW> sbi only works on low regs
[14:02:53] <Laurenceb> ok
[14:03:12] <RikusW> ori = or immediate
[14:03:14] <RikusW> aka constant
[14:03:31] <RikusW> *sbi only works on low IO
[14:03:45] <Laurenceb> ok it builds now, thanks
[14:03:50] <Laurenceb> :D
[14:03:51] <Laurenceb> cya
[14:03:52] <RikusW> ori and all over immediates work only or r16-r31
[14:54:13] <Tekkkz> RattusRattus: okay, it still ignored my OCRnA value if im using timer1, so we will se tomorrow how to fix this, yepß
[14:54:15] <Tekkkz> *?
[15:39:03] <N1njaneer> Hooray, locked in our descision for new pick and place this afternoon.
[15:41:14] <Tom_itx> did you ask for the world?
[15:44:51] <N1njaneer> Shouldn't you always? :D
[15:45:54] <N1njaneer> Always sucks when you have to try to do apples-to-apples comparisons between equally good contenders.
[17:29:59] <aczid> would anyone here happen to have experience driving the em4095 RFID chip from an AVR?
[17:32:28] <aczid> it's a pretty neat chip. I'm using the clock it gives me as an input to a timer to wait for a number of cycles between modulations of the field through another output pin
[17:33:09] <aczid> but I think I'll need my logic analyzer to see if the timings I end up with are correct