#avr Logs

Aug 23 2018

#avr Calendar

02:18 AM rue_bed: ok
05:54 AM [1]MrMobius is now known as MrMobius
11:43 AM gruetzko- is now known as gruetzkopf
12:38 PM Jan-: hihi avr people.
12:38 PM Jan-: I have hit a bit of a problem. I need to use the analog comparator on the atmega328p, so I am using PD6 and PD7 (AIN0 and AIN1).
12:38 PM Jan-: However I also need to do PWM waveform generation with automatic pin toggling on OC0A.
12:38 PM Jan-: ....which is also PD6.
12:38 PM Jan-: Ummm. Suggestions?
12:39 PM Jan-: can I tell the analog comparator to use other analog input pins?
12:51 PM johnbeard: Jan-: pretty sure the comparator can only use those pins, but can you use OC0B?
12:52 PM Jan-: yes that's what I'm discovering
12:52 PM Jan-: and yes I can
12:52 PM Jan-: but I'm a bit confused by the datasheet wording
12:52 PM Jan-: https://pastebin.com/Ld37J97x
12:53 PM Jan-: This option is not available for the OC0B
12:53 PM Jan-: pin.
12:54 PM Jan-: but later in the discussion of TCCR1A it says that COM1B1 and COM1B0 bits control "toggle OC1A/OC1B on Compare Match"
12:54 PM Jan-: I'm not sure what the datasheet is referring to with the words "this option"
12:54 PM Jan-: which option?
12:54 PM Jan-: toggling on compare match? Something else?
12:57 PM johnbeard: look at Table 19-4 compared to Table 19-7
12:57 PM Jan-: bear with me I'm doing this with a screenreader
12:59 PM johnbeard: on OC0A, if you set COM0A[1:0] to 01 you can either be disconnected, or "toggle on compare match", depending on WGM02
12:59 PM Jan-: hang on I can do it
12:59 PM johnbeard: on OC0B, COM0B[1:0] = 01 is reserved, you can only have disconnected, set or clear
01:08 PM Jan-: it's in table 19-6 on the pdf I have
01:08 PM Jan-: "toggle oc0b on compare match"
01:08 PM Jan-: but that only works when WGM0 isn't set to "fast pwm mode"
01:08 PM Jan-: I'm not sure where that leaves me
01:09 PM johnbeard: 19-6 for me is for CTC mode
01:10 PM Jan-: Table 19-6. Compare Output Mode, non-PWM
01:10 PM Jan-: http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-42735-8-bit-AVR-Microcontroller-ATmega328-328P_Datasheet.pdf
01:10 PM Jan-: I need to toggle the pin on compare match. I'm not actually generating PWM, I'm generating SMPTE-12M linear timecode. I don't know if I need "fast pwm mode" or not.
01:11 PM johnbeard: fast PWM is just twice as fast as "normal"
01:11 PM Jan-: I need to toggle the pin something like every 4000 clocks or so
01:11 PM johnbeard: yeah, you'll be ok with non-fast PWM modes
01:12 PM Jan-: so I *can* have oc0b toggle on compare match.
01:12 PM johnbeard: yes
01:12 PM Jan-: Phew.
01:12 PM johnbeard: but not in fast pwm mode
01:12 PM * Jan- winds her heartbeat down from a high pitched whine to a mere buzzing sound
01:13 PM johnbeard: the text you linked is specifically abut fast pwm mode
01:13 PM Jan-: it's not *super* clear.
01:13 PM johnbeard: well, it does start "In Fast PWM mode..." :-p
01:13 PM johnbeard: but yes, the timer documentation is rather dense
01:13 PM * Jan- sticks out her tongue
01:14 PM Jan-: I wonder why it's like that.
01:14 PM Jan-: Just some sort of implementation detail I guess.
01:14 PM johnbeard: presumably
01:14 PM Jan-: a lot of the transistors on this thing must just be option switching
01:14 PM johnbeard: or it was supposed to work, but it was broken, so they just said it doesn't work
01:14 PM Jan-: would they do that :D
01:15 PM Jan-: when did they last actually make new masks for atmega328s I wonder...
01:15 PM johnbeard: xmegas are worse (better?), they have tons of remapping going on
01:16 PM johnbeard: anyway, glad you survive to fight another problem :-D
01:16 PM Jan-: the problem with this that it's all critical timing
01:16 PM Jan-: so once I'm "basically done" I have another 400 years of adding NOPs to things so it all lines up to the clock cycle
01:21 PM Jan-: if a ddr is set to 0, does that pin become high impedance
01:38 PM Jan-: oh god these timers :(
01:38 PM * Jan- puts on hat with heatsink and fan
02:42 PM The_CooIest: Would an Atmega328 survive being powered from 3.3v but being connected to another device with a 5v IO?
02:47 PM Emil: Consider joining #avrs
03:33 PM johnbeard: The_CooIest: from the datasheet: Max voltage on any pin except !RESET: -0.5V to VCC+0.5V
03:34 PM johnbeard: so, no
03:34 PM The_CooIest: yep, thanks.
09:33 PM LoRez is now known as Guest81479
11:27 PM day__ is now known as day