#avr Logs

Feb 26 2019

#avr Calendar

03:01 AM cehteh: meh ... got this pololu programmer, looks dead,
03:11 AM cehteh: grr bad usb cable
03:16 AM cehteh: ok dlashing in 6.2 secs instead 20+s :)
03:28 AM crispy_ is now known as Guest80872
03:29 AM janco_ is now known as janco
03:38 AM chutulu_ is now known as chutulu
06:33 AM day_ is now known as day
06:56 AM Maya-sama is now known as Miyu
06:58 AM janco_ is now known as janco
07:11 AM Thrashbarg_ is now known as Thrashbarg
07:34 AM nohit: --
12:55 PM HelloShitty: Hello
12:56 PM HelloShitty: I need help checking 2 lines of code to see why they are not the same
12:56 PM HelloShitty: I have this line of code that is working:
12:56 PM HelloShitty: TCA0_SINGLE_CTRLB = 0x11;
12:56 PM HelloShitty: and I tried to replace it with these 2:
12:56 PM HelloShitty: TCA0_SINGLE_CTRLB = ~( (1 << 0x02) | (1 << 0x01));
12:57 PM HelloShitty: TCA0_SINGLE_CTRLB = ((1 << 0x10) | (1 << 0x00));
12:57 PM HelloShitty: But these 2 are not working because I can't see the same result in my scope... Line 1 (with some more lines of code)
12:57 PM HelloShitty: produces a 5KHz pulse train
12:58 PM nohit: well line 2 overrides line 1
12:58 PM HelloShitty: the 2 other lines of code just a flat line at 0V
12:58 PM HelloShitty: Line one sets bits 4 and 1, right?
12:59 PM HelloShitty: and the other 2 lines are doing basically the same (so I thought)
12:59 PM HelloShitty: but apparently I'm missing some detail
01:00 PM HelloShitty: TCA0_SINGLE_CTRLB = ~( (1 << 0x02) | (1 << 0x01)); unsets bits 2 and 1 and keep all the others
01:00 PM HelloShitty: TCA0_SINGLE_CTRLB = ((1 << 0x10) | (1 << 0x00)); sets bits 4 and 0 and keeps all the others, no?
01:01 PM HelloShitty: I'm sorry, I'm missing the & and the | in the 2 lines
01:01 PM HelloShitty: I meant:
01:01 PM HelloShitty: this TCA0_SINGLE_CTRLB = 0x11;
01:02 PM HelloShitty: to be the same as:
01:02 PM HelloShitty: TCA0_SINGLE_CTRLB &= ~( (1 << 0x02) | (1 << 0x01));
01:02 PM HelloShitty: and
01:02 PM HelloShitty: TCA0_SINGLE_CTRLB |= ((1 << 0x10) | (1 << 0x00));
01:04 PM nohit: seems right to me code-wise
01:05 PM HelloShitty: But it's not outputting the same result
01:08 PM nohit: TCA0_SINGLE_CTRLB |= ((1 << 4) | (1 << 0));
01:08 PM nohit: sets bits 4 and 0
01:09 PM nohit: TCA0_SINGLE_CTRLB |= ((1 << 0x10) | (1 << 0x00)); sets bits 16 and 0
01:09 PM nohit: dont use hex with the bit values
01:10 PM HelloShitty: hum, ok... I see now
01:11 PM HelloShitty: But 4 or 0x04 is the same, right?=
01:12 PM nohit: ye
01:12 PM nohit: s
01:12 PM HelloShitty: TCA0_SINGLE_CTRLB = ~( (1 << 0x02) | (1 << 0x01));
01:12 PM HelloShitty: TCA0_SINGLE_CTRLB = ((1 << 0x04) | (1 << 0x00));
01:12 PM HelloShitty: Still not working
01:13 PM HelloShitty: shit
01:13 PM HelloShitty: missing the & and | again
01:15 PM nohit: but like i said, dont use hex with bit values
01:15 PM HelloShitty: yeah, ok
01:17 PM nohit: in the header file there's bit masks that u can use
01:17 PM nohit: but setting individual bits like that is most clear way imo
01:17 PM nohit: i never use macros
01:18 PM nohit: example of bit mask: TCA0_SINGLE_CTRLA |= (TCA_SINGLE_ENABLE_bm); //Enable timer
01:19 PM HelloShitty: Yes, I know
01:19 PM HelloShitty: and that has been my struggle
01:19 PM HelloShitty: Between searching the MACROS in the header file
01:19 PM HelloShitty: understanding the _gc, _bp, _bm, etc
01:20 PM HelloShitty: and reading the datasheet searching for the meaning of each register
01:20 PM nohit: by macros i meant SetBit(PORT, BIT) ClearBit(PORT, BIT)
01:20 PM HelloShitty: has been quite a struggle to me that I'm just starting with this mega4808
01:21 PM HelloShitty: Yes, but also what I said is not easy for a first time
01:21 PM HelloShitty: because I need to try to guess the macros names
01:21 PM nohit: yeah
01:22 PM HelloShitty: so, search the datasheet for the register names and then search the header file for the MACROS they used for each register and each register's properties, so to speak
01:22 PM HelloShitty: microchip engineers came with this structs, unions and enums solution to make life easier
01:22 PM HelloShitty: but that comes with a cost for beginners, imo
01:23 PM nohit: true
01:23 PM HelloShitty: last 2 days I went through the TCA section of the datasheet but couldn't make this work
01:24 PM HelloShitty: I was trying to produce a 5KHz pulse train
01:24 PM HelloShitty: but the datasheet is a bit confusing in my opinion
01:24 PM HelloShitty: because the order of events that I think are important to make things work, is not very clear
01:25 PM HelloShitty: when someone like me doesn't fully know the chip
01:27 PM nohit: that's pretty cheap chip
01:28 PM nohit: 1,14 € on mouser
01:31 PM HelloShitty: yeah, I won this board AVR IoT WG in some forum contest
01:31 PM HelloShitty: in AVR Freaks forum
01:31 PM HelloShitty: And now I'm starting to learn how to program this chip
03:03 PM PoppaVic: OK, I am getting frustrated. what is the THREE byte order of stack pushes and pops for a far call and return?
03:04 PM PoppaVic: This should be a trivial 'google' but I am going blind.. If I were to guess, I'd say PCL PCH EIND
03:27 PM polprog: https://www.microchip.com/webdoc/avrassembler/avrassembler.wb_CALL.html
03:28 PM polprog: the order of bytes depends on avr endianness
03:29 PM polprog: which to be honest i dont know what endianness avrs have and what each endianness looks on stack :p
03:29 PM PoppaVic: um, yeah.. except.. not: it's 2 or 3 bytes - period. bytes ain't endian; CALL does something RETURN exhumes - so, it's simple
03:29 PM polprog: the PC is 16 bits, thats two bytes, so it does matter
03:29 PM polprog: why do you need that even
03:30 PM polprog: 16 or even 22 bits
03:30 PM * PoppaVic sighs
03:30 PM polprog: what
03:30 PM PoppaVic: because I can form my own call-pushes and return. because I want stack-order of that info for a VM
03:31 PM PoppaVic: well, they can say "22 bit" all day, and it's still 24bit
03:33 PM polprog: so 3 bytes. and you wanna know the order of those 3 bytes on the stack after a call, right?
03:33 PM PoppaVic: yes
03:34 PM PoppaVic: or the 2 bytes and order after the call. I can't find a doc that states the ORDER
03:37 PM nohit: that would be easy to figure out on a simulator
03:38 PM PoppaVic: Cool, so - what's it say - and does it match the chip?
03:38 PM nohit: try it on atmel studio simulator
03:39 PM PoppaVic: not likely - nodoze
03:43 PM polprog: Now run the code. After the first break the SRAM will hold 0x04 at address 0xDF and 0x00 at address 0xDE. That means that the low byte of the address (which is 0x04) is at the higher address.
03:43 PM polprog: http://www.avrbeginners.net/architecture/stack/stack.html
03:44 PM polprog: little endian
03:44 PM polprog: fascinating. it wasnt in the datasheet
03:45 PM polprog: nighters
06:37 PM [1]MrMobius is now known as MrMobius
07:51 PM mwette: If I have "task_state: .comm task_state_data,64" in my asm source and later reference the symbols, is task_state the address and task_state_data the value?
07:53 PM rue_mohr: between C and assemler?
07:55 PM mwette: no, all assembler; later I have "ldi r28,lo8(task_state)"
07:56 PM mwette: where I hope the ldi is loading the lo 8 bits of task_state into r28
09:35 PM rue_shop1: been a while since I did assmbler
09:35 PM rue_shop1: I'd name all the registers
09:35 PM rue_shop1: A, B, C, D, E, H, L, X, Y... you know...
09:41 PM rue_shop1: awe, nobody even gets that joke :(
09:45 PM rue_shop1: no, dude, your the only one alive
09:45 PM rue_shop1: hu?
09:46 PM rue_shop1: there IS NOBODY ELSE to be able TO get that joke
09:46 PM rue_shop1: awe...
10:00 PM Thrashbarg: I was saying boo-urns
10:11 PM rue_shop1: mhm
11:26 PM day_ is now known as day
11:50 PM [1]MrMobius is now known as MrMobius