#avr | Logs for 2015-11-01

Back
[21:14:03] <Quantumcross> Hi nerds
[21:14:37] <Quantumcross> I'm pretty newbie and playing around with an arduino nano programmed externally via ISP
[21:14:44] <Quantumcross> and I'm having a really weird problem with my output pins
[21:15:14] <Quantumcross> I'm getting 2.5V when I write a 1 to the pin, and either 0V or 5V when I write a 0...
[21:16:39] <Quantumcross> I'm guessing I have some register configured incorrectly
[21:18:55] <Quantumcross> either that or USB isn't providing enough power
[21:20:00] <apo_> What's connected to the pin?
[21:20:23] <apo_> And if USB isn't providing enough power you're shorting your atmega
[21:22:44] <Quantumcross> on the output pin? just a resistor -> led -> gnd
[21:24:01] <apo_> remove and try again =P
[21:26:30] <Quantumcross> without anything on the pin, I measure 2.5 when high, and 0 or like 4.5 when low (random???)
[21:27:20] <apo_> Is your ddr set to output?
[21:28:17] <Quantumcross> DRB |= (1<<DDB0)|(1<<DDB1);
[21:28:26] <Quantumcross> (it's happening on both those pins)
[21:29:34] <Quantumcross> and I'm setting it from an input pin like so: encB = ((PIND>>PD5) & 1); PORTB ^= (encA<<PB0);
[21:30:26] <apo_> Uh
[21:30:32] <apo_> That's a lot of complexity
[21:30:52] <apo_> Reduce your code to the simplest example that doesn't work
[21:31:10] <Quantumcross> sure I'll just blink the led
[21:31:32] <apo_> start with something that just turns the output on when it starts, then idles
[21:31:32] <apo_> etc
[21:32:19] <Quantumcross> I had it blinking before and it looked fine
[21:32:58] <apo_> You're probably toggling too quickly
[21:33:30] <Quantumcross> maybe the switch is bouncing? why would that cause it to settle in a 2.5V state though?
[21:33:37] <apo_> No
[21:33:45] <apo_> it can't 'settle' at 2.5V
[21:33:53] <apo_> You're turning it on and off all the time
[21:33:58] <Quantumcross> when I push and hold a button, I read 2.5V at the output
[21:34:01] <Quantumcross> hmm
[21:34:08] <apo_> ^= toggles
[21:34:14] <apo_> you're probably running that in your main loop
[21:34:24] <apo_> every time it goes through that, it switches between on and off
[21:35:41] <Quantumcross> oh I see what you're saying
[21:35:43] <Quantumcross> shoot
[21:35:45] <Quantumcross> hang on
[21:35:51] <Quantumcross> relearning my bits
[21:40:49] <Quantumcross> yeah that's the problem
[21:40:57] <Quantumcross> just bitwise operations hurting my head
[21:41:17] <Quantumcross> not sure what to use to set a pin to the value of a variable
[21:43:23] <apo_> port |= mask; port &= ~mask;
[21:43:57] <Quantumcross> yeah but that's specifically set and clear, I have a variable that's 0 or 1, I guess I can just if statement it
[21:45:49] <Quantumcross> yay it works and is responsive
[21:46:06] <Quantumcross> there's gotta be a fancy bitwise way of doing it, I'll think about it later
[21:46:07] <Quantumcross> thanks!!!
[21:46:40] <apo_> no problem
[21:46:44] <apo_> Off to bed now \o