#avr | Logs for 2015-10-16

Back
[06:14:40] <cart_man> Hello everyone. I have this PWM finally set up and working http://pastebin.com/W8pMDFcM ...but now I have a problem. I do not know how to use the same counter as a normal counter to use with just TCNT1 and check its value? I usually build counters that checks the TCNT1 >6500 and if it is it will increment a variable and set TCNT1 = 0; ...Should I set up another counter rather? If so which one?
[06:28:23] <apo__> if you reset tcnt1 to 0 at 6500 you'll get 6.5ms period instead of 20ms
[06:28:31] <apo__> use another counter
[06:31:15] <apo__> (You can still read it, of course.)
[07:15:35] <cart_man> apo__: Yea but then I can not go if (TCNT1 >= 65000) { DO your job};
[07:15:44] <cart_man> :( ok I will try and use another counter
[07:34:57] <apo__> cart_man: if you use PWM with a top value of 20k you won't ever reach 65k...
[07:35:42] <cart_man> apo__: Yes that is right... I thought so too
[07:43:31] <cart_man> apo__: Timer0 does not have 16 bits though
[07:43:59] <cart_man> apo__: 8 bit is very small also : ' |
[07:44:55] <cart_man> apo__: Maybe if I have a very large prescaler I can poll TCNT0 to check if (200>= TCNT0) {increment this double};
[07:45:00] <apo__> use a prescaler
[07:45:33] <apo__> or increment a counter in your interrupt
[07:45:36] <apo__> or use a different uC
[07:46:02] <cart_man> apo__: Lol dammit I have like 200 Atmega328s lying around hahah
[07:47:01] <apo__> Use two -> two 16-bit timers. :p
[07:50:16] <cart_man> apo__: hahahah yea...or just use one as an external clock!
[07:51:37] <cart_man> apo__: Ok this is my last question for you ... if I have a 16Mhz clock and a 1024 prescaler...is it correct to say (16000000)/(1024) = 15625 would be the resulting frequency for that timer?
[07:52:06] <apo__> cart_man: Yes
[09:55:23] <gorroth> cart_man: yeah, the 8-bit PWMs is pretty dang small for a lot of peripherals out there. i'm hoping to build up my library at some point to make the 8-bit PWM behave like the 16-bit PWM (with software help), and i'll release that on my public repo
[09:55:58] <cart_man> gorroth: That would be awesome !
[09:57:47] <gorroth> well, it's on my todo list after i get some more of my other stuff working :) i'd say it might be 3rd or 4th on the list, atm
[10:07:09] <Strangework> gorroth, how is that your job gives you so much free time?
[10:07:17] <Strangework> It sounds like a dream
[10:19:42] <gorroth> Strangework: well, i work from 9-5 most of the time, which is normal. sometimes i have to work more hours, but i use my own time to do this extra stuff, which is my own personal sacrifice :)
[10:20:32] <gorroth> plus, i'm very experienced at this point, and what might take one person a lot of time to do something at work will take me a lot less time
[10:20:42] <gorroth> so i can just move faster and be able to leave work at normal hours
[10:21:23] <Strangework> ah! So you just use your time well.. ;) That's an invaluable skill
[10:21:34] <gorroth> plus, i've become very passionate about this project, which pushes me to do more. i mean, it's not like someone would normally want to spend 10 hours on a saturday working on it, hehe
[10:21:50] <gorroth> :)
[10:33:52] <Strangework> Giving a (strong) shit about things is commendable.
[10:33:59] <Strangework> God bless your lawn mower
[10:37:11] <gorroth> lol
[10:37:19] <gorroth> it's a weird thing to care about
[10:37:28] <gorroth> when i talk about it, i feel like a redneck
[10:38:34] <gorroth> "Whatcha buildin' there?" "Oh this here contraption? It's my lawn cuttin' machine, 'cept I don't have to ride it! It just cuts the lawn all by itself." "Well, I'll be darned."
[12:18:24] <hetii> Hi
[12:20:17] <hetii> Lambda_Aurigae: Q: Do you have any idea why my laser printer block itself on paper used to transfer toner for PCB and for normal regular one all is fine. Till yesterday I print on such paper fine but today i`m not able...
[12:20:33] <hetii> Its HP laserjet 1020
[12:45:10] <cart_man> Hi... on the Atmega328P... what does the TCCR2B differ from TCCR0A ?
[12:45:25] <LeoNerd> Presumably: refers to timer 2 instead of timer 0 ?
[12:48:01] <cart_man> LeoNerd,Yes but what does the A and B mean?
[12:49:32] <LeoNerd> The A, B, ... registers are just sections of control bits
[12:49:51] <LeoNerd> There's more than 8 bits of control information so they're distributed over Control Register A, Control Register B, etc...
[12:51:32] <cart_man> LeoNerd,Sorry I DCed ... I do not know if you replied
[12:53:23] <LeoNerd> <LeoNerd> The A, B, ... registers are just sections of control bits | <LeoNerd> There's more than 8 bits of control information so they're distributed over Control Register A, Control Register B, etc...
[12:55:24] <gorroth> cart_man: btw, you mixed 2B and 0A; 2B is for TCNT2 and 0A is for TCNT0
[12:55:38] <gorroth> just so you know those particular registers aren't connected
[12:55:45] <gorroth> TCCR0A and TCCR0B are though
[12:56:32] <LeoNerd> TCCR0A and TCCR0B are really just 16 bits-worth of control bits for timer 0
[12:56:43] <LeoNerd> The splitting of exactly which bits go in CR A and which in CR B is fairly arbitrary
[12:57:13] <gorroth> yeah
[13:01:43] <cart_man> LeoNerd,OMG this makes sooooooo much more sense now... I was soo confused
[13:01:53] <cart_man> gorroth,^^ Thanks you guys
[13:02:34] <LeoNerd> Some chips have a timer with CR C as well
[15:04:17] <cart_man> Is this all I need to start the 8bit Timer 2 ? -> TCCR2A |= 0b00000000; TCCR2B |= 0b00000111;
[15:05:46] <cart_man> sorry i dc the entire time... anybody said anything?
[15:13:00] <cart_man> dced again : /
[15:40:53] <osteri> IMO that is not the best design choice by Atmel to call them A and B
[15:42:55] <osteri> makes it kind a confusing
[16:07:25] <pooof> Hi guys... can someone plaese tell me why my LED wont blink? I have the timer set up right ?
[16:07:26] <pooof> http://pastebin.com/VgGmkLUL
[16:09:18] <Thrashbarg> pooof: while (;;) is invalid to begin with. It's either for(;;) or while(1), not both
[16:11:02] <pooof> Thrashbarg: Ok but apart from that
[16:11:37] <Thrashbarg> apart from that the timer does the counting, not the software
[16:12:59] <Thrashbarg> pooof: wait how long did you want between LED flashes??
[16:13:36] <Thrashbarg> rough guess from the code suggests several minutes?
[16:13:49] <pooof> Thrashbarg: Well like in the region of 1 second...but I realize now that I might have something like 7.06x10^12 seconds
[16:14:02] <Thrashbarg> yeah...
[16:14:25] <pooof> But even if I put the Led toggle function i any of the other functions it does not work
[16:15:41] <Thrashbarg> what ATmega were you using?
[16:16:04] <pooof> Thrashbarg: Atmega328p with 8Mhz
[16:18:27] <Thrashbarg> pooof: also, you're setting the flags for timer/counter 2 (TCCR2A, TCCR2B) but reading from timer/counter 0
[16:19:42] <pooof> Yes I changed it to TCNT2 but still not working
[16:20:03] <pooof> Thrashbarg: Got happy when I saw it cause I thought it would be the problem...but didnt
[16:22:42] <Thrashbarg> you'll need to make sure you're setting the right bits in TCCR2x as well, they're different from TCCR0x
[16:22:50] <Thrashbarg> IIRC
[16:24:41] <Thrashbarg> that is, COM0A1 WGM00 WGM01 are flags for timer0, not sure if they're the same in timer2
[18:29:24] <Lambda_Aurigae> hetii, no clue. not sure what you mean by "block itself"
[18:51:23] <Lambda_Aurigae> http://hackaday.com/2015/10/16/code-craft-when-define-is-considered-harmful/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+hackaday%2FLgoM+%28Hack+a+Day%29
[18:51:33] <Lambda_Aurigae> a good writeup on #defines and macros and how things can go right and horribly wrong.
[19:44:28] <FrankD> can anyone give me advice on how to use the USI in SPI mode to shift 18 bits in/out?
[19:50:32] <LeoNerd> 8 8 2
[19:52:32] <Lambda_Aurigae> or 8 8 8 and ignore the last 6
[22:34:56] <FrankD> Can't the USI handle up to 16 bits?
[22:35:02] <FrankD> how do you configure the overflow counter?
[22:53:54] <gorroth> when you say USI, I guess you really mean the UART. I haven't used it in SPI mode, but the UART only has an 8-bit data register. so you will have to deal with it 8-bits at a time
[23:07:31] * Xark notes USI is for assisted "bit-bang" of UART or SPI (and related). However, 8-bits only (and you cannot set data reg while it is being output - no buffer like normal UART).