#avr | Logs for 2015-01-13

Back
[03:12:48] <STS_Patrik> any suggestion on methods for determining hardware product version for a MCU?
[03:13:41] <STS_Patrik> suggestions so far is making pull-up/pull-down on unused GPIO pins or NFC-IC's with serial interface
[03:14:01] <hypermagic> set it as output ?
[03:14:10] <hypermagic> nothing else required
[03:14:46] <hypermagic> pulldown is not good, and pins used to have weak pullup that can be enabled.
[03:16:08] <STS_Patrik> i don't think you understand my problem. The MCU gets new software version distributed and needs to make pin mappings based on it's hardware version
[03:16:34] <STS_Patrik> so i need a way for the MCU to determine which version of hardware its running
[03:16:49] <hackvana> Why not just wire different pins to Vcc and GND?
[03:17:00] <hackvana> New PCB version, new Vcc/GND pattern
[03:17:22] <STS_Patrik> ye thats one of the solutions ive considered
[03:17:29] <hackvana> Let's say you need 4 bits, with 4 GPIOs
[03:17:55] <hackvana> You could turn on the AVR's internal 10k pullups, and then have pads for a resistor between the GPIO and ground.
[03:18:24] <hackvana> If you want the GPIO to read zero, fit a 1k resistor. If you want the GPIO resistor to read 1, don't fit a resistor.
[03:18:25] <STS_Patrik> is that a common method of doing that? feels like the last resort solution
[03:18:40] <hackvana> The advantage of this is it can be updated after the board is made.
[03:18:43] <hackvana> Very.
[03:19:00] <STS_Patrik> disadvantage, might need those pins in future versions
[03:19:10] <hackvana> Another idea that uses only one pin (but an ADC channel): Turn on the 10k pullup resistor, then
[03:19:21] <hackvana> fit different resistor values between the pin and GND.
[03:19:39] <hackvana> The internal resistor and external resistor make a voltage divder.
[03:19:40] <STS_Patrik> ye thats an alternative
[03:19:53] <hackvana> You can read the midpoint voltage with the ADC.
[03:20:38] <hypermagic> i use one version mcu for a board
[03:21:00] <hypermagic> and i can use that board for a million purpose.
[03:22:39] * hackvana shrugs
[03:25:16] <hypermagic> hey twnqx
[03:25:54] <twnqx> hey hypermagic
[03:25:58] <hypermagic> what are you up to now ?
[03:26:25] <twnqx> figuring out why my PC suddenly switched its screen to mirroring instead of dual desktop.
[03:26:42] <hypermagic> what linux you use?
[03:27:19] <twnqx> gentoo
[03:27:20] <twnqx> w
[03:27:23] <twnqx> and fixed
[03:27:57] <hypermagic> now more mcu magic ?
[03:28:50] <twnqx> haha
[03:28:57] <twnqx> nah
[03:30:10] <twnqx> hm
[03:30:21] <twnqx> i think i'll have a few of those boards made
[03:30:44] <hypermagic> my cookie oven is soon to be retired ;<
[03:30:46] <twnqx> and hand them out at a demo party in april :3
[03:31:15] <hypermagic> i will reclassify it as reflow oven
[03:32:51] <hypermagic> it is only 9L and impossible to clean anyway
[03:34:54] <hypermagic> do you think my next cooking oven should be spherical or a flatter disc shape ? there is not much point in having a tall oven i think, you simply can not bake a 50cm tall bread
[03:37:45] <twnqx> but 50 cm pizza :3
[03:37:58] <hypermagic> that is not tall :)
[03:38:15] <hypermagic> sure one can bake a few cm tall disc or slug
[03:38:50] <hypermagic> 100cmx30cmx5cm bread
[04:18:57] <edmont> i'm trying to upgrade one board that uses a 802.15.4 transceiver (SoC) with a RF front-end. The problem is that RF posositive and negative RF terminals are crossed when putting both chips together, and i wouldn't like to make vias for the RF path. What would happen if i connect positive output of the transceiver with negative input of the front-end (and vice versa)?
[04:53:08] <gea22> Is anyone there?
[04:54:11] <DO9XE> yes :)
[04:56:18] <gea22> I have a question if you don't mind :). Why do I constantly see people using 'cbi PORTx, y' to set an output high? Isn't setting the bit of a PORT the way to toogle it to a high state?
[04:56:30] <gea22> ie sbi
[04:57:56] <gea22> For example here http://necrobious.blogspot.jp/2010/06/avr-asm-first-steps.html
[05:03:05] <LeoNerd> SBI and CBI are short for "Set BIt" and "Clear BIt" respectively, yes.
[05:06:21] <gea22> LeoNerd: yes but what I mean is that shouldn't cbi or clear bit set the output to a LOW rather than a high?
[05:06:29] <LeoNerd> That it does, yes.
[05:07:12] <gea22> Then why do I keep seeing comments that say cbi sets the output to a HIGH. Does it differ from micro to another?
[05:07:30] <LeoNerd> Perhaps the comment is wrong? :)
[05:07:42] <gea22> Well I've seen many references
[05:07:56] <gea22> Even here http://www.avrbeginners.net/getting_started/starter_2_2.html
[05:08:21] <LeoNerd> Alternatively, maybe there's extra hardware involved... e.g. a PNP transistor on the output pin.. setting the pin -itself- low, would pull down current through the transistor from VCC, causing the collector output of the transistor to go high
[05:08:58] <LeoNerd> Yah, the comment doesn't say "high"
[05:09:08] <LeoNerd> The comment says: ; switch it on (referring to the LED)
[05:09:28] <LeoNerd> Where is the LED connected? I'm going to bet: VCC to PB3
[05:09:45] <gea22> I thought there was no external transistor, if that's the case then yeah I understand. But that's strange putting a PNP in anycase rather than a more common NPN
[05:09:53] <LeoNerd> "As the LED is ON when PortB.3 is low, the LED can be switched on with cbi and off with sbi. Let's add that to the loop:"
[05:10:07] <LeoNerd> ^-- this would suggest that interpretation ;)
[05:10:53] <LeoNerd> Don't think of driving high and driving low, as "on" and "off" - both are active driving states... Just one is actively pulled up to VCC, the other is actively pulled down to GND
[05:11:02] <LeoNerd> Either could be considered "on" depending on what else is connected and how
[05:12:03] <gea22> So a HIGH state is one in which the circuit is connected to VCC and vice versa?
[05:12:32] <LeoNerd> Yes
[05:12:46] <LeoNerd> All the AVR chips have full push-pull drivers on all the output pins
[05:13:00] <gea22> And a pin configured as an INPUT is just one with a high impedance?
[05:13:25] <LeoNerd> Yes.. effectively what the DDRx register does is enable or disable the pushpull driver
[05:14:08] <LeoNerd> With the bit in DDRx clear, the pushpull driver is disabled; it doesn't matter what the PORTx bit is, the line is neither pulled up to VCC nor down to GND, so it floats at hi-Z unless driven by the external circuit
[05:14:27] <LeoNerd> With the bit in DDRx set, the driver is enabled, and will pull either up to VCC or down to GND, depending on the PORTx bit
[05:14:59] <LeoNerd> Totally independently of that, the PINx register always lets you read the logic state of that pin
[05:15:52] <gea22> LeoNerd: Ah I see and this pushpull driver, what impedance does it usually have?
[05:16:00] <LeoNerd> It helps to think of the DDRx register in this term, not as its name suggests "data direction register"... You can always read the PINx even in "output" mode; you can still use the pin as an "output" for hi-Z
[05:16:23] <LeoNerd> It's a pair of FETs to VCC or GND, so... probably tiny... well under 1ohm I should hope
[05:16:26] <LeoNerd> The datasheet likely says
[05:19:48] <LeoNerd> Ah; it doesn't say ver
[05:19:59] <LeoNerd> y directly... it's not a simple response
[05:20:15] <LeoNerd> In any case, it's "small" and unlikely to matter. You shouldn't be drawing large current from it anyway
[05:20:17] <gea22> "If PORTxn is written logic one when the pin is c onfigured as an input pin, the pull-up resistor is activated" How can the value of the port not matter though with DDRx clear.
[05:21:13] <LeoNerd> Ah; that.
[05:21:18] <LeoNerd> That's an ordering thing :)
[05:21:53] <LeoNerd> If you clear DDR, the pin becomes an input, and the -current- value of PORTx doesn't matter.
[05:22:48] <LeoNerd> I think... actually, I might be misremembering now
[05:22:55] <gea22> Yeah I guess so that's essentially a high impedance path, a resistor, that gets 'activated' essentially to the driver
[05:23:10] <LeoNerd> The resistor is separate from the push/pull FETs
[05:23:33] <gea22> It is present near the pins correct?
[05:23:48] <LeoNerd> Mm?
[05:24:16] <gea22> I mean the internal resistor that gets activated when writing to a port configured as an input
[05:24:44] <LeoNerd> Oh, yes.. electrically it's basically right next to the actual physical pin, up close to the "outside"
[05:25:41] <gea22> And a pin configured as an INPUT is basically connected to ground correct?
[05:26:32] <LeoNerd> No, not at all... as an input it's hi-Z; not driven either way
[05:26:54] <LeoNerd> If it was connected to ground, that would be a LOW output... so it wouldn't be possible to sense the voltage level
[05:28:06] <gea22> Sorry to sound idiotic but then how does the driver complete the circuit for voltage measurement?
[05:28:31] <LeoNerd> Hrm? It's compared to the ground and supply lines of the chip itself
[05:28:49] <LeoNerd> The input sense logic compares the voltage on the pin, to the GND level the chip itself is at
[05:29:25] <gea22> So there is no direct connection from the pin to anything else inside the chip
[05:29:48] <LeoNerd> Uhm.. define "direct"
[05:30:00] <gea22> I mean forming a closed circuit
[05:30:25] <LeoNerd> It forms a "circuit" of sorts, but that circuit is at a huuuuuge impedance.. typically in the hundreds of Mohm level...
[05:30:37] <gea22> AH I see
[05:30:43] <LeoNerd> I.e. basically no current will flow
[05:31:32] <LeoNerd> I think at this point, you might want to look at how a MOSFET works... specifically, go read about the way that the gate is "isolated" from the drain-source channel; allowing G to control D-S without actually any current flowing through G
[05:31:48] <LeoNerd> I have to head out to the dentist now, so I'll leave you there
[05:32:00] <gea22> Because somethimes I see people switching their pin mode from an output to an input. Ie in a ps/2 driver
[05:32:15] <LeoNerd> Yes.. as I said earlier, don't think of it as "output" or "input" mode...
[05:32:17] <gea22> LeoNerd: Oh but thanks for all the help :)
[05:32:28] <LeoNerd> Think of DDR as being called "push-pull driver enable"
[05:33:00] <LeoNerd> DDR set => pin is driven high/low. DDR clear => pin floats at hi-Z. In either mode, you can always read the level from PIN
[05:33:30] <LeoNerd> Anyway, must go.
[05:33:43] <gea22> Thanks again I REALLY appreciate it :))
[06:35:16] <Lambda-Aurigae> STS_Patrik, does your design use the internal eeprom for anything?
[06:51:30] <Lambda-Aurigae> STS_Patrik, or, do you have one ADC pin available? you could use different values of a resistor pair to make different readings for different versions..
[06:51:44] <Lambda-Aurigae> or, heck, one resistor even...
[06:52:13] <Lambda-Aurigae> 330ohm, 1K, 2K, 5K, 10K..
[07:15:34] <inflex> Ugh, why is it, when you spin a PCB, it's always the parts you *don't* create provide multiple footprints for that end up needing to be changed because of a supplier issue
[07:27:17] <STS_Patrik> @ Lambda-Aurigae: Ye, that solution was suggested by hackvana and was one way of doing it I didn't know before.
[07:27:59] <STS_Patrik> sounds like a better solution than locking up more gpio pins to create a binary pattern
[07:28:16] <hackvana> Break out all the pins and leave them as pads. You never know when they'll come in useful :-)
[07:28:33] <STS_Patrik> I'm quite space limited
[07:29:52] <hackvana> STS_Patrik: In #hackvana we use gerblook.org to give others a look at our PCBs.
[07:30:32] <hackvana> For example: http://gerblook.org/pcb/9RB7aAwdqWQS4ZdDfh7Sc4
[07:30:57] <STS_Patrik> ah i c
[07:31:28] <hackvana> That way we can invite feedback, and improve the design.
[07:34:24] <hackvana> STS_Patrik: (I can show you that because it's open source. I'd never share a design that wasn't open)
[07:35:11] <STS_Patrik> I did'nt know about hackvana before. We've been using oshpark for non-time-critical proto pcb's
[07:36:33] <hackvana> Haha, I can have boards in your hand in 5 days.
[07:38:12] <STS_Patrik> We've been using eurocircuits for that but I'm open to try something new :)
[07:39:25] <hackvana> oshpark is a good company.
[07:43:36] <DO9XE> elecrow, too :) 10 PCBs, 5x5cm, for under 10$
[07:43:51] <LeoNerd> I like oshpark
[07:44:07] <LeoNerd> Mostly because they do batches of 3
[07:46:51] <hackvana> There are now several very budget suppliers
[07:49:22] <LeoNerd> I tried dirtypbc a few weeks ago. Somewhat lower quality than oshpark
[07:49:30] <LeoNerd> The silkscreening in particular is actually fairly terrible
[07:49:39] <STS_Patrik> regarding my hardware version tracking i had a vision of having a NFC way of speaking to the MCU.
[07:50:21] <hackvana> LeoNerd: It lives up to its name
[07:50:23] <STS_Patrik> i2c to MCU & NFC to phone
[07:50:25] <hackvana> Sometimes that's ok
[07:50:52] <hackvana> I prefer to charge a little more and provide a LOT more service, and boards are in the "great" category.
[07:51:22] * hackvana is feeling uncomfortable because I don't really want to spam #avr
[07:52:32] <LeoNerd> There's certainly room to have both kinds of service around. Sometimes you want cheap and dirty, for prototyping. I don't think I'd use dirtypcb to build a board I was intending to sell as a "real" product, but fine for initial hackery
[07:52:40] <LeoNerd> Except, their smallest run is 10, so... less so :)
[07:54:49] <hackvana> I tell my customers to use spares to teach youngsters to solder
[07:55:08] <hackvana> They can also be used around edges of stencils
[07:55:09] <LeoNerd> Mm... if I did teaching I'd consdier that.
[07:55:23] <hackvana> You guys seen this? http://www.hoektronics.com/2012/10/27/super-simple-smt-stencil8/
[07:58:08] <LeoNerd> So, to change the subject entirely to something actually AVR-related: I'm planning a two-MCU board, with a tiny84 and a tiny2313. Both have a USI onboard.
[07:58:24] <inflex> hackvana: fine if you've got the $$$. I cut my stencils with a vinyl cutter, hand applied the the pasting, and used a modified pizza oven :)
[07:58:30] <LeoNerd> I'm already using the 84's USI as SPI to talk to a radio module. Does it seem sensible to reuse that to have it talk SPI also to the other tiny?
[07:59:30] <LeoNerd> Also, on the 2313, how nicely can I implement an SPI slave?
[08:05:02] <hackvana> inflex: Do it :-)
[08:05:29] <hackvana> inflex: I'd do just the same :-)
[08:13:18] <LeoNerd> Basically my thoughts are: Should I try to SPI between the two tiny chips using USI? That seems easier than trying to I2C them over USI, and have to somehow work out how to make the 84 do I2C and SPI separately.
[08:13:51] <LeoNerd> It seems that SPI is the only thing they'll share that is hardware-assisted.. I -could- use the 2313's UART and softserial the 84, but I have no timing crystal so that sounds prone to failure
[09:03:20] <LeoNerd> so, hrm.. has anyone used USI as an SPI slave before? How should I manage the SS logic?
[09:22:34] <LeoNerd> Hrm. silence. Maybe I'm breaking new ground here that nobody else has trodden
[09:36:10] <uniqdom> Does anyone recognize the IDE to open a .pro file?
[09:36:40] <LeoNerd> Could be anything
[09:36:45] <LeoNerd> KiCad writes .pro files
[09:36:49] <LeoNerd> Probably Eagle too. differnet kind
[09:37:24] <LeoNerd> I'd 'file' and 'view' it, see if there's any hints that way
[09:37:41] <uniqdom> I'm stuck trying to figure one the IDE to open that kind of project. well it is suppossed to be a source code project, for atmega1284P
[09:38:03] <LeoNerd> So what does file say?
[09:38:32] <uniqdom> this are the files that I have in the project folder http://pbrd.co/1y9RAZ6
[09:38:41] <uniqdom> let me copy the file contents
[09:39:08] <LeoNerd> Er.. no. 'file'. The utility for identifying file types
[09:39:23] <uniqdom> ok
[09:40:43] <uniqdom> swarm-ranging-demo.pro: automake makefile script, ASCII text, with CRLF line terminators
[09:42:39] <uniqdom> and this is the content of the .pro file http://pastebin.com/3vW1WURv
[09:42:47] <uniqdom> LeoNerd: -^
[09:43:06] <twnqx> ms visual c++ does use those as well
[09:43:10] <twnqx> and IDEs based on it
[09:43:26] <twnqx> though
[09:43:30] <uniqdom> could it be AVR studio?
[09:43:44] <twnqx> possibly
[09:43:44] <twnqx> or eclipse
[09:44:10] <twnqx> i never use IDEs... so i wouldn't know :P
[09:44:11] <uniqdom> well... i have failed with avr stduio 4, 5 and 6... i will try eclipse
[09:44:19] <twnqx> tried arduino?
[09:44:56] <twnqx> though that looke like a make dialect
[09:45:02] <twnqx> maybe cmake?
[09:45:29] <uniqdom> thats what i see... but the original developer seems to have been working on Windows
[09:45:49] <uniqdom> maybe he was using cygwin or something else
[09:47:01] <uniqdom> http://pastebin.com/Be1zMcVY
[09:54:55] <twnqx> ah
[09:55:00] <twnqx> so qt project files
[09:55:05] <twnqx> that qmake converts into makefiles
[09:55:53] <uniqdom> twnqx, so there is not IDE at all?
[09:56:02] <uniqdom> no*
[09:59:08] <twnqx> not necessarily, no
[09:59:32] <twnqx> that's qt's equivalent of a ./configure
[10:00:48] <uniqdom> ok... I have opened the .pro file with QTcreator, I think that it worked, it is building now. thanks
[10:03:38] <uniqdom> It worked... thanks twnqx and LeoNerd
[10:03:42] <LeoNerd> :)
[10:06:17] <inflex> lo there twnqx
[10:06:43] <twnqx> lo
[10:34:32] <redstonecraftpl> hi guys
[10:34:57] <redstonecraftpl> i wrote mini block schematic of my atmega computer
[10:35:14] <redstonecraftpl> cpu-atmega 8
[10:35:27] <redstonecraftpl> gpu-atmega 88/168
[10:36:18] <redstonecraftpl> sound fx/mus+load and save from/to cassette - atmega8/attinyX
[10:36:48] <redstonecraftpl> keyboard µc-attinyX
[10:37:09] <redstonecraftpl> port multiplier-atmega8
[10:37:14] <redstonecraftpl> thats all
[10:37:17] <redstonecraftpl> relog
[10:37:30] <LeoNerd> .. strange chap
[10:38:20] <twnqx> and... why would he even go that way
[10:38:25] <twnqx> instead of just usign an fpga or an arm...
[10:38:30] <twnqx> for far less money...
[10:39:08] <LeoNerd> FPGAs usually don't have the "home constructor can have an entire dev. environment for $10" that AVRs do
[10:39:51] <twnqx> not?
[10:40:01] <twnqx> software is free from all players
[10:40:21] <twnqx> small spartans are around the 10$ mark, too
[10:40:23] <LeoNerd> Software, sure.. What about hardware?
[10:40:37] <LeoNerd> Can I buy a USB-to-chip widget and put the chip in my breadboard... all for that?
[10:40:42] <twnqx> (no idea about altera, lattice ot microsemi)
[10:41:07] <LeoNerd> I've always been put off the idea of FPGAs because of that
[10:41:24] <twnqx> you can use any tqfp breakout board :P
[10:41:30] <LeoNerd> I have this admittedly ill-researched first impression in my head that I'd need ~$300 to get anywhere with it
[10:41:34] <twnqx> lol
[10:41:36] <LeoNerd> And I can't be bothered for that price
[10:41:45] <twnqx> nah, that's a bit much :P
[10:42:09] <twnqx> at least for spartan 3 all you need for jtag is a ft2232
[10:42:29] <LeoNerd> Annoyingly the Bus Pirate doesn't do JTAG :/
[10:42:29] <twnqx> or a xilinx parallel port clone
[10:42:42] <twnqx> that wouldn't help you since you also need software to program
[10:42:46] <LeoNerd> I dunno.. maybe it's all perception
[10:42:55] <twnqx> it is :P
[10:42:58] <LeoNerd> So go fix that
[10:43:01] <twnqx> what country do you live in again?
[10:43:12] <LeoNerd> Go write me a "I know nothing, I want to copypaste lines of text from a webpage and make an LED flash" tutorial
[10:43:15] <LeoNerd> UK
[10:43:46] <twnqx> do i have my minimal blinky still here :P
[10:43:59] <twnqx> in about 10 lines of verilog D:
[10:44:20] <LeoNerd> It's not just the code. it's the whole environment
[10:44:28] <uniqdom> LeoNerd, are you sure that Bus Pirate doesn't do JTAG?
[10:44:37] <twnqx> peronally i use a 200$ xilinx jtag mark 2 :P
[10:44:49] <twnqx> stay away from fpgas with the bus pirate
[10:44:58] <LeoNerd> You need to teach someone who starts off knowing nothing "Go buy these tools [links to ebay], wire them up like this, install this program [link to debian package], write this Makefile, run these commands, then see the LED blink""
[10:44:58] <twnqx> it doesn't even have level shifting
[10:45:15] <uniqdom> ok
[10:45:16] <twnqx> and jtag perfers isolation because there's no standard voltage
[10:45:25] <twnqx> (my own fpga deisgn uses 2.5V JTAG)
[10:45:32] <LeoNerd> I'm sure it's easy enough to build an isolator
[10:45:40] <LeoNerd> JTAG doesn't have any I2C-style bidir wires
[10:45:54] <twnqx> because i couldn't be arsed to implement a third voltage regulator. oh how i annoy myself with this...
[10:45:55] <LeoNerd> Infact it's SPI-like isn't it? I reckon a 1401 would do
[10:46:03] <LeoNerd> 3out, 1in
[10:46:18] <twnqx> make that 5 out, 1 in
[10:46:42] <twnqx> or well, 4/1
[10:46:52] <LeoNerd> Hrm. Well, OK but hopefluly some are slow enough that a slower converter chip would fill thos ein
[10:46:58] <LeoNerd> save the 1401 for clock/data
[10:47:28] <twnqx> i just use 74lvch2t45dc
[10:47:31] <twnqx> three of them
[10:47:32] <LeoNerd> http://dangerousprototypes.com/bus-pirate-manual/bus-pirate-jtag-guide/
[10:47:33] <uniqdom> i was thinking about purchasing a bus pirate... do you recommend it?
[10:47:34] <LeoNerd> Huhh....
[10:47:45] <twnqx> i have one
[10:47:51] <twnqx> i use it for SPI mainly
[10:47:52] <LeoNerd> uniqdom: Eh.. it's not bad. It's not /amazing/ and I'm slowly working on ideas for a much nicer one. But it's a start. and it's cheap
[10:48:11] <LeoNerd> My complaints about the BP: Binary mode is verymuch a second citizen; so much you can't do over binary that you can over text.
[10:48:17] <LeoNerd> No interrupts. No current meter
[10:48:59] <LeoNerd> This page seems to suggest the BP -can- do JTAG
[10:49:15] <twnqx> probably just have to change the firmware
[10:49:43] <uniqdom> yes that's why i have asked...
[10:50:27] <LeoNerd> I can't remmeber offhand; I'll take a look in the menu of mine tonight. Maybe it is in stock firmware
[10:51:04] <uniqdom> i have read that it works with avrdude
[10:51:30] <uniqdom> "avrdude -p ?" shows that it is supported.
[10:51:36] <LeoNerd> Mmmm.. a bit slow though
[10:51:46] <LeoNerd> Honestly, even a $3 USBASP board is nicer
[10:52:12] <uniqdom> what about the Bus Blaster?
[10:52:21] <uniqdom> i have one... but i have never used it
[10:52:49] <LeoNerd> https://en.wikipedia.org/wiki/Joint_Test_Action_Group <== diagram here makes it look like JTAG is basically SPI
[10:54:05] <LeoNerd> Anyway, that looks exactly the sort of thing a 1401 can do
[10:56:37] <LeoNerd> If I actually had any hardware that talked JTAG I'd consider adding it to Device::BusPirate
[11:00:04] <uniqdom> +1
[11:01:12] <twnqx> you don't?
[11:01:18] <twnqx> i use jtag to program my avrs :P
[11:01:51] <LeoNerd> I mostly work on tinies currently
[11:02:05] <LeoNerd> Except for my mega328 but that's on an Arduino Nano board, so USB'able
[11:08:21] <LeoNerd> mega328 doesn't claim to do JTAG
[16:10:06] <davor> there's a register where bits 7:2 are reserved and bits 1 and 0 are R/W, and I need to write 0 to them. do I just do EIMSK = 0x00; or is there another/a better way?
[16:13:08] <specing> davor: cbi?
[16:13:29] <specing> the datasheet usually says what to do with the rest
[16:13:46] <davor> cbi?
[16:13:59] <specing> its an instruction
[16:14:27] <specing> read-modify-write bit clear
[16:15:10] <davor> datasheet says 7:2 will always read as 0, I don't need to do anything with them
[16:15:10] <davor> ahh nice
[16:15:30] <davor> so I'd just do cbi(EIMSK,1); cbi(EIMSK,0); then right?
[16:16:19] <tk`> why not EIMSK &= ~(1+2);
[16:16:23] <davor> I could've also used sbi(WDTSCR,WDCE); instead of WDTCSR |= (1<<WDCE); too
[16:17:09] <tk`> but cbi and sbi looks cleaner
[16:17:21] <davor> is there any difference between the two approaches?
[16:18:17] <davor> I suppose with =, &=, |= etc I can set/unset multiple bits at once which can't be done with a single cbi/sbi instruction right?
[16:18:58] <tk`> cbi and sbi in C
[16:19:00] <tk`> are just macros
[16:19:10] <tk`> like
[16:19:27] <tk`> sbi(reg, bit) reg |= (1<<bit)
[16:19:33] <LeoNerd> cbi() and sbi() used to be useful because they used to be asm { ... } wrappers
[16:19:52] <LeoNerd> Now that gcc can understand when to use the CBI / SBI instructions natively for single-bit |= and &= it tends not to be useful any more
[16:20:19] <davor> mm, I see, interesting
[16:20:20] <davor> thanks
[16:20:24] <specing> |= and &= for single bit always seemed dumb to me
[16:20:49] <specing> I have a #define cbi and #define sbi that insert assembly
[16:21:11] <LeoNerd> Also, "readable" is entirely subjective. I've got so used to FOOR |= _BV(FLAG); that it just reads naturally to me, I can "see" what it does just fine
[16:21:16] <specing> well set_bit(addr, pos), clear_bit(addr, pos)
[16:21:38] <tk`> it also depends on what kind of register you are setting
[16:21:45] <tk`> some will be compiled to sbi/cbi
[16:21:51] <tk`> some to in, sbr, out
[16:22:03] <tk`> i'd rather set multiple bits in one line, anyway
[16:27:14] <stanreg> Would anyone have pseudocode of a serial byte-receiving function? (start bit, 8 data, 1 parity, 1 stop)
[16:27:47] <LeoNerd> You want to look for "avr softserial"
[16:27:56] <stanreg> ty
[16:29:32] <Tom_itx> http://tom-itx.no-ip.biz:81/~webpage/avr/LCD/Serial_LCD/4bit_mode/
[16:29:36] <Tom_itx> that might have something in it
[16:30:01] <Tom_itx> http://tom-itx.no-ip.biz:81/~webpage/avr/rs232_rx_test/
[16:30:03] <LeoNerd> Tom_itx: you're a likely person to know this one - ever implemented an SPI slave on a 'tiny using the USI?
[16:30:03] <Tom_itx> as well as that
[16:30:18] <Tom_itx> HELL no!
[16:30:29] <Tom_itx> from what i hear USI sucks the big one
[16:30:47] <Tom_itx> i have done spi though
[16:30:48] <LeoNerd> Mm.. I've done SPI master from it just fine... it's as nice as the real ATmega SPI module to be honest.
[16:31:20] <Tom_itx> well there was _something_ about it that was kinda nasty... it may not have been SPI
[16:31:21] <LeoNerd> Setup is identical ("write some config into some registers"), sending is only a tiny bit more effort in that you have to toggle the clock line yourself
[16:31:38] <LeoNerd> I2C over USI is pretty awkward, as you have to do the I2C start/stop transactions in software
[16:31:56] <Tom_itx> maybe that was it
[16:32:45] <LeoNerd> I'm just wondering, for implementing an SPI slave, how to do the SS triggering
[16:32:57] <LeoNerd> The AVR note on the subject is quite brief; just suggests using one of the INT pins
[16:33:11] <Tom_itx> well on master you have to init the SS line
[16:33:17] <Tom_itx> you may need to with slave
[16:33:34] <Tom_itx> from there, you can use other IO to trigger multiple slaves
[16:33:53] <Tom_itx> i assume you have to init the SS line on slave too
[16:33:55] <LeoNerd> On the master it's easy though; when I want to talk I just CBI the relevant bit in PORTx, then SBI it at the end
[16:34:11] <Tom_itx> set SS as input
[16:34:11] <LeoNerd> On the slave, I'll have to int-trigger it, and set.. er.. something up when that happens.. *shrug* ?
[16:34:27] <Tom_itx> i don't think so
[16:34:40] <malinus> LeoNerd: I usually (on master ofc.), just have a function called writeSpi, which handles the SS, and writes to the data register.
[16:34:44] <Tom_itx> just so the slave is set to talk to the master
[16:34:49] <Tom_itx> CPOL CPHA
[16:34:52] <LeoNerd> malinus: yes; master I can do fine
[16:35:07] <malinus> LeoNerd: on the slave, you just read the data register when the SPI interrupt triggers, no?
[16:35:13] <LeoNerd> "the SPI interrupt" ?
[16:35:15] <malinus> yes
[16:35:18] <Tom_itx> yeah
[16:35:21] <LeoNerd> There isn't one. This is an ATtiny with USI, not an ATmega
[16:35:23] <LeoNerd> It has no SPI module
[16:35:29] <malinus> oh, my bad, carry on
[16:36:00] <LeoNerd> OK.. so.. On the falling edge of the SS INT pin, I think what I have to do is poke the USI into saying "OK you should receive stuff now"
[16:36:02] <Tom_itx> i suppose you would either poll the SS line or something
[16:36:22] <LeoNerd> Then the master's clock will drive the USI into clocking the bits in, and when an entire byte has arrived the USI's overflow interrupt fires.. and I read a byte from that
[16:36:24] <Tom_itx> that would be the 'something'
[16:36:45] <LeoNerd> I just don't have a detailed idea in my mind of what that "something" is just yet
[16:36:53] <LeoNerd> Hrm. I suppose it's an easy thing to write to test
[16:37:06] <LeoNerd> Maybe I'll see if I can implement a 74'595 in software.. that's a good start actually
[16:37:09] <Tom_itx> on some devices the slave will tell the master when data is available i think
[16:38:28] <Tom_itx> it's been quite a while since i did anything with SPI
[16:39:39] <LeoNerd> I think SPI is my only real choice for this. I want to comm. between a tiny84 and a tiny2313
[16:40:01] <LeoNerd> Neither has hardware SPI/I2C, but both have USI. the 2313 has a UART though, but the 84 not
[16:40:27] <malinus> LeoNerd: what's wrong with software UART?
[16:40:46] <LeoNerd> the 84 doesn't have a timing crystal because it's not doing anything (else) timing-sensitive
[16:40:53] <LeoNerd> I don't like UART'ing without a crystal anyway
[16:41:34] * Tom_itx gies LeoNerd a TTY keypad to clock with
[16:41:50] <LeoNerd> Well that's the beauty of SPI between them.. neither needs an accurate clock
[16:42:13] <LeoNerd> Plus I can be -really- cheeky with ISP
[16:42:59] <Tom_itx> i liked the spi on the 68332 because you could tell it how many bits to wait for
[16:42:59] <LeoNerd> The same lines are tied together for the USI ring, as are used for ISP, so if I attach ISP to one of the chips, I get the other one "for free" by swapping MISO<->MOSI and providing a second RESET line
[16:43:10] <LeoNerd> So 7 external pins let me ISP both of the chips
[16:43:23] <LeoNerd> Tom_itx: oh, the USI can do that :)
[16:43:34] <Tom_itx> i've never messed with the USI
[16:43:45] <LeoNerd> Preload the USI counter module with 0/2/4/6/8/... to work in 8/7/6/5/4/... bit words
[16:44:06] <LeoNerd> The USI overflow interrupt happens when the counter overflows to 16. normally it just resets to 0, with two counter ticks per shifted bit.
[16:44:08] <Tom_itx> what about 9 or 12?
[16:44:13] <LeoNerd> That's more fun
[16:44:17] <Tom_itx> heh
[16:44:25] <Tom_itx> the 68332 was 16bit :)
[16:44:31] <LeoNerd> 12 bits, for example: preload it with 8, to do the first 4 bits, then let it continue to overflow an entire second time
[16:44:43] <LeoNerd> 9 bits: preload it with 14, let it overflow and then again
[16:44:45] <LeoNerd> etc
[16:44:52] <Tom_itx> i know you can do it, just takes more work
[16:44:57] <LeoNerd> Ohsure..
[16:45:07] <LeoNerd> It's more work, but it's still much easier than doing it totally by software
[16:45:15] <LeoNerd> I like to think of it as "hardware-assisted software SPI"
[16:53:37] <tk`> is there any way I can tell avr-gcc that the function is totally static, so it doesn't have to use ldd's and std's, just static lds and sts?
[16:59:17] <mssbrg> hi all, I'm having trouble understanding how writing to registers works in avr c code
[16:59:41] <tk`> it depends on what kind of register you are writing to
[17:00:04] <tk`> but any more specific question?
[17:00:50] <mssbrg> sorry, the guys in ##electronics just got back to me, I will come back here if I'm still unsure
[17:02:45] <MarkX> i'm looking for someone who made an LED device that you can upload messages to using an AUX cable
[17:02:51] <MarkX> anyone know who I am talking about?
[17:04:52] <LeoNerd> "using an AUX cable" ?
[17:05:10] <MarkX> a 3.5mm audio cable
[17:05:27] <MarkX> he talks in this channel
[17:05:37] <MarkX> as well as ##hackvana
[17:05:45] <MarkX> err #hackvana *
[17:11:32] <davor> argh
[17:14:34] <davor> I want to make an atmega328p wake up every 4 seconds using watchdog. after setting the wdt for 512K cycles and putting the device to sleep, something keeps waking it up a split second after it goes to sleep, instead of waiting 4 seconds. it goes to pwr_down mode where the only things that can wake it up are bod (which is disabled with sleep_bod_disable();), INT0, INT1 and TWI address match (which are supposed to be disabled by clearing EIMSK, PCICR, TWCR
[17:14:34] <davor> and PCMSK0, 1 and 2 registers)
[17:14:43] <davor> I have no idea what it is that's still waking it up instead of wdt
[17:14:45] <malinus> MarkX: you want Jartza
[17:15:02] <MarkX> malinus: thats it!
[17:15:05] <MarkX> thanks!
[17:16:24] <malinus> davor: remember to have the routine there, even if it's empty
[17:16:43] <malinus> otherwise it just jumps to a random places (or restarts)
[17:16:43] <davor> what routine?
[17:16:55] <malinus> isr
[17:16:58] <malinus> for watchdog
[17:18:25] <davor> ahh right, thanks man
[17:19:52] <malinus> davor: look under empty interrupt www.nongnu.org/avr-libc/user-manual/group__avr__interrupts.html
[17:19:57] <malinus> to do it the "proper" way
[17:20:14] <malinus> (will probably be smaller than making a normal empty isr routine)
[17:28:26] <davor> ah thanks man!
[17:32:39] <malinus> davor: it works?
[17:32:50] <davor> yep
[17:32:57] <malinus> nice
[17:34:33] <LeoNerd> Anyone happen to know if the ~IRQ line on an nRF24L01 is pushpull driven, or open-collector?
[17:35:02] <LeoNerd> Wondering if I can wire-or them together, or if I'll have to isolate it with a transistor. The datasheet is vague
[17:36:17] <malinus> why would you ever need to wire two of those together though
[17:36:27] <LeoNerd> Well, not two nRFs, but one nRF and one other chip
[17:36:36] <malinus> ah
[17:37:17] <LeoNerd> Since you can bus all the MISO/MOSI/SCK lines together I was hoping I could bus the IRQ lines of my chips together, and when the INT fires, ask each in turn if it's happy
[17:39:09] <LeoNerd> http://www.electronicspoint.com/threads/nrf24l01.268061/ much doubting on the internet.. nobody seems to know :/
[17:49:12] <LeoNerd> Hrm.. I may have to put a 74'07 in there instead then. :/ booo
[20:16:32] <mssbrg> is there any way to look up the commonly used/useful avr-libc macros?
[20:16:56] <mssbrg> I just noticed _BV() in some code I was looking at but probably would have never know about it otherwise
[20:17:31] <Tom_itx> i prefer the old method
[20:17:35] <Tom_itx> it's more readable
[20:17:59] <Lambda-Aurigae> http://www.nongnu.org/avr-libc/user-manual/index.html
[20:18:36] <Lambda-Aurigae> http://www.nongnu.org/avr-libc/user-manual/modules.html actual library reference.
[20:21:44] <Lambda-Aurigae> http://www.nongnu.org/avr-libc/user-manual/group__avr__sfr.html here is your specific docs on _BV() and similar stuff.
[20:33:12] <mssbrg> thanks!