#avr Logs

May 01 2021

#avr Calendar

10:46 AM splud is now known as Jck_off
10:53 AM Jck_off is now known as splud
02:17 PM mindw0rk_ is now known as mindw0rk
03:35 PM rue_shop1: have all the fuses been calculated?
03:35 PM rue_shop1: http://www.engbedded.com/fusecalc/
06:11 PM rue_mohr: so, my timer config didn't work
06:11 PM rue_mohr: tiny85, I want to output Fio/2 from timer 0
06:12 PM rue_mohr: TCCR0B = ( 1 << WGM01 ); // WGM02 = 1, CS02 = 0, CS01 = 0, CS00 = 1
06:12 PM rue_mohr: TCCR0A = (( 1 << COM0A0 ) | ( 1 << WGM01 ) | ( 1 << WGM00 )); // COM0A1 = 0, COM0A0 = 1, WGM01 = 1, WGM00 = 1
06:12 PM rue_mohr: OCR0A = 0; // immediate toggle
06:12 PM rue_mohr: TCCR0B |= ( 1 << CS00 ); // enable
06:12 PM rue_mohr: anyone see an error?
06:22 PM exp: in the first line you use WGM01 to address WGM02
06:22 PM exp: and i don't see any change to port direction
06:23 PM rue_shop1: the port is ok, the timer isn't outputting the right freq
06:23 PM rue_shop1: oh I see
06:23 PM rue_shop1: hah
06:23 PM rue_shop1: fixing thats a good start
06:23 PM rue_shop1: it was written at 2am
06:24 PM exp: for a long time i've been trying to understand how you could augment a programming language to detect something like that, without it becoming Rust
06:25 PM rue_shop1: oo\
06:25 PM exp: i'm not typing out an explanation of how i managed it... because it turns out it's bloody hard
06:26 PM exp: i have only rough hypotheses, which require months of boring work to even try and push forward
06:26 PM exp: anyway, hope that got it working for you
06:27 PM rue_shop1: I think you got it
06:27 PM rue_shop1: my crystal is a bit out of tune, but yea!
06:27 PM rue_shop1: next timer
06:28 PM exp: warm it up a bit :)
06:28 PM rue_shop1: I didn't put any caps on it, and its on a breadboard
06:28 PM rue_shop1: and its a chinese crystal
06:28 PM exp: i'm about to spend a fortune on a crystal somewhere around 0.5ppb over a lot of °C
06:28 PM exp: cause we're looking into what it takes to make a GPSDO
06:28 PM rue_shop1: ok, The next timer issue is more complex
06:29 PM rue_shop1: [internal clock] 8 Mhz *8 = 32MHz /16 = 4MHz
06:29 PM rue_shop1: the system clock for timer 0 came from an external crystal
06:29 PM rue_shop1: timer 1 is being used off the pll
06:29 PM exp: 8*8 is not 32
06:29 PM rue_shop1: oh yea, 2am math
06:29 PM exp: lol
06:29 PM exp: but 64/16 is 4
06:30 PM rue_shop1: [internal clock] 8 Mhz *8 = 64MHz /16 = 4MHz
06:30 PM rue_shop1: :D
06:30 PM rue_shop1: COM1A1 = 0, COM1A0 = 1, CS13 = 0, CS12 = 0, CS11 = 0, CS10 = 1
06:30 PM rue_shop1: are the setting I devised to do this
06:30 PM rue_shop1: code is
06:30 PM rue_shop1: OCR1C = 7; // DIVIDE BY 8
06:30 PM rue_shop1: PLLCSR = (( 1 << PCKE ) | ( 1 << PLLE )); // PCKE = 1, PLLE = 1,
06:30 PM rue_shop1: TCCR1 = (( 1 << COM1A0 ) | ( 1 << CS10 )) ; // COM1A1 = , COM1A0 = 1 , CS13 = 0, CS12 = 0, CS11 = 0, CS10 = 1
06:30 PM rue_shop1:
06:31 PM exp: i'm not very up on the avr range
06:31 PM rue_shop1: right now, its outputting 128kHz
06:31 PM exp: but iirc on the at90s i use, the timers aren't clocked directly from the system
06:31 PM exp: but from one of the subsidiary clocks, maybe io?
06:31 PM rue_shop1: it should be 4Mhz
06:31 PM rue_shop1: on the t85 you can run the timers from different clocks
06:31 PM rue_shop1: the pll can only run from the internal 8Mhz
06:32 PM rue_shop1: and, because I'm shooting for 4Mhz, and "PCLK must be more than 3x core clock freq" and my core freq is going to be 18.432MHz...
06:32 PM rue_shop1: I have to go with 64Mhz
06:33 PM exp: what are you driving, just out of interest? i'll have a quick read of the registers in the datasheet now
06:33 PM rue_shop1: a z80 and a uart
06:34 PM rue_shop1: I just need a clock gen, the tiny85 seems to be the most compact way of doing it
06:35 PM exp: yeah that makes sense, i am currently making some relatively high power battery boards, and i am considering putting a tiny avr on there
06:35 PM exp: need to be able to reflash it from another avr on a main distro board though
06:35 PM rue_shop1: heh, does ANYONE EVERY ACTUALLY release firmware updates?
06:36 PM exp: we're doing absurdly rapid iteration with clients, so yeah definitely
06:38 PM rue_shop1: "The bit PCKE can only be set, if the PLL has been enabled earlier."
06:38 PM exp: i was about to ask if you've checked the pll lock
06:39 PM exp: but just going through tccr now :)
06:39 PM rue_shop1: hell no
06:39 PM rue_shop1: rewriting...
06:41 PM exp: are you sure you have the correct WGM mode?
06:41 PM exp: #3 vs #7?
06:41 PM rue_shop1: // turning on the pll is a process...
06:41 PM rue_shop1: PLLCSR |= (1<<PLLE);
06:41 PM rue_shop1: while (IsLow(PLOCK, PLLCSR)); // wait for pll to lock
06:41 PM rue_shop1: PLLCSR |= (1<<PCKE);
06:41 PM rue_shop1:
06:41 PM rue_shop1: OCR1C = 7; // DIVIDE BY 8
06:41 PM rue_shop1: TCCR1 = (( 1 << COM1A0 ) | ( 1 << CS10 )) ; // COM1A1 = , COM1A0 = 1 , CS13 = 0, CS12 = 0, CS11 = 0, CS10 = 1
06:41 PM rue_shop1:
06:41 PM rue_shop1:
06:41 PM rue_shop1: lets try this...
06:41 PM rue_shop1: I'm dividing by 16
06:42 PM rue_shop1: so I have the wgm in toggle mode
06:42 PM rue_shop1: and I set the loop to 8 instead of 16
06:42 PM rue_shop1: -1 because apparently thats a thing.
06:43 PM exp: but you have it set to use 0xFF as TOP, instead of OCR
06:43 PM exp: so you'll get 256/8 the frequency you expect
06:43 PM exp: ie 128khz
06:43 PM rue_shop1: OCR1C is top?
06:44 PM exp: not w/the WGM bits you selected?
06:44 PM rue_shop1: what did I miss
06:44 PM rue_shop1: but timer1 doesn't have wgm?
06:44 PM * rue_shop1 re-reads
06:44 PM exp: maybe i misread, let me also check
06:45 PM rue_shop1: timer 0 has a wgm, but 1 is all funkey
06:45 PM exp: yeah page 79 is correct for TCCR0A WGM i think
06:45 PM exp: oh sorry
06:45 PM exp: i am reading your previous settings
06:45 PM rue_shop1: np
06:45 PM rue_shop1: your correction was right for timer0, its working now
06:46 PM exp: for TCCR1 shouldn't you be setting CTC1?
06:46 PM exp: same effect, different cause?
06:47 PM rue_shop1: ok, let me read for a sec, iirc there were two ways to do the exact same thing
06:48 PM exp: disclaimer: also past midnight for me :)
06:49 PM rue_shop1: oh it makes it loop
06:49 PM rue_shop1: huh
06:50 PM exp: if it doesn't, OCR1C is p much only controlling phase, not dividing
06:50 PM rue_shop1: yea, thats different
06:50 PM rue_shop1: you got it!
06:50 PM exp: maybe i'm misreading what you're setting, i don't think i'm being much help
06:50 PM exp: oh lol
06:50 PM exp: good timing
06:51 PM rue_shop1: and omg that needs a tuning
06:51 PM exp: does it matter if it's a clock source?
06:51 PM rue_shop1: like I say, timer1 is really strange, I think it had a different engineer
06:51 PM exp: z80 not got much tolerance
06:51 PM rue_shop1: and I suspect their normal timer design couldn't do 64Mhz
06:51 PM rue_shop1: hah
06:52 PM rue_shop1: I dont mind overclocking it by .17Mhz
06:52 PM rue_shop1: I might play with the tuning register too
06:52 PM rue_shop1: COOL!
06:52 PM exp: what are you measuring it with?
06:52 PM rue_shop1: freq meter
06:53 PM rue_shop1: LDC-822, its good
06:53 PM rue_shop1: the RC will be out
06:53 PM exp: just curious :)
06:53 PM rue_shop1: osccal...
06:53 PM rue_shop1: somewhere..
06:53 PM exp: i don't have a good frequency counter yet, but looking forward to playing w/a 12 digit one if we do this project
06:54 PM rue_shop1: 12, wow
06:54 PM exp: it's for GPS stuff so it's ridiculous
06:54 PM exp: they can literally sample for more than a year and produce continuous statistics
06:54 PM rue_shop1: mine is 7, and I have not seen many things that stable
06:54 PM exp: i am legitimately going to have to buy a UPS just for it
06:54 PM rue_shop1: ah
06:55 PM exp: rue_shop1: there's an analog devices chip which has an appnote about building a GPSDO
06:55 PM exp: so we're just going to give it a shot
06:55 PM exp: and tl;dr: because the control loop bandwidth is absurdly low, mHz, you need a reference clock which is extremely stable to begin with
06:56 PM exp: we're aiming at a 3-5 fold improvement in holdover, but i need to investigate just how these things age, hence sampling for a year
06:56 PM rue_shop1: cool
06:57 PM exp: it is p neat, i'm very much out of my depth
06:57 PM exp: the maths is complex, but the concept is relatively simple
06:57 PM rue_shop1: I tried to do a 10MHz vco, and could NOT get it even close to basic stability
06:57 PM rue_shop1: at one point it changed freq when I walked up to it
06:58 PM rue_shop1: THATS sensitive
06:58 PM exp: hah seriously
06:58 PM exp: i've never tried a VCO, i've had to deal with plenty of loop stability problems though
06:58 PM rue_shop1: I was watching the counter
06:58 PM exp: i'm slowly beginning to understand network analysis
06:58 PM rue_shop1: I wanted 1-10Mhz
06:58 PM rue_shop1: and I got it, about 900k - 1.1Mhz
06:58 PM rue_shop1: but stability
06:59 PM rue_shop1: and I couldn't get a servo loop to hold it
06:59 PM rue_shop1: so I ended up using the DDS chip
06:59 PM exp: it sounds like you were coupling a lot of noise in somewhere
06:59 PM rue_shop1: a good one,
06:59 PM rue_shop1: and thermal noise
06:59 PM exp: dds is black magic
07:00 PM rue_shop1: I mean, it went up like 200Hz when I was standing close to it
07:00 PM exp: how can it possibly be a better option to more or less read a sine wave from ram
07:00 PM rue_shop1: i was just going digital
07:00 PM rue_shop1: I made a freq gen
07:00 PM rue_shop1: just ttl square wave out, which is most of what I use
07:00 PM exp: enough smart people work on them that i am sure that it is the better option, but i do not understand why at all
07:01 PM exp: i just have some cheap off the shelf one, i do need to build some PLLs and test them in ltspice for practice
07:01 PM rue_shop1: http://ruemohr.org/%7Eircjunk/projects/freqGen/slide.htm
07:01 PM rue_shop1: lots of stuff not told, but that was the basic story
07:01 PM exp: my desk is beginning to look like that
07:02 PM exp: i've been trying to clear up while simultaneously cataloguing hundreds of parts because of shortage and also building a bunch of boards
07:02 PM exp: it's sisyphean
07:03 PM rue_shop1: :)
07:18 PM specing_ is now known as specing
07:55 PM ephemer0l is now known as GeneralDiscource
07:56 PM GeneralDiscource is now known as ephemer0l_