#avr Logs

Mar 31 2020

#avr Calendar

03:21 AM Thrashbarg_ is now known as Thrashbarg
03:59 AM davor_ is now known as davor
05:24 AM matthias_arch: I have a question about inlining the millis() function in the following code snippet. https://godbolt.org/z/bQepsB The compiler is instructed to optimize for size but in this case a function call takes longer because of the uint32_t transfer. Why doesn't the compiler inline automatically?
05:25 AM matthias_arch: The compiler does it only with O2/O3
10:10 AM mouseghost is now known as desperek
10:11 AM desperek is now known as mouseghost
12:03 PM lvlinux is now known as ruel
12:04 PM ruel is now known as ruhnet
12:07 PM ruhnet is now known as lvlinux
03:09 PM chinry: Been working on a project using the atmega328p. I am having trouble getting SPI to work. So far SPDR is being written to and is triggering the interrupt flag, yet nothing is being transmitted over the actual port. Is there a way I could share my assembly program?
03:09 PM Fuchikoma: pastebin?
03:09 PM chinry: sure
03:10 PM Fuchikoma: Is your device master or slave?
03:13 PM chinry: https://pastebin.com/whsxPn0v
03:13 PM chinry: master
03:14 PM Fuchikoma: Okay, so you need to make sure the pins are properly configured for input/output and that the SPI clock is configured
03:15 PM chinry: I have my fuses setup properly I think.
03:15 PM Fuchikoma: Which I guess the clock is fine if the interrupt flag you're referring to is the transmit done flag
03:15 PM chinry: yes
03:15 PM Fuchikoma: You should nto ahve to mess with the fuses
03:15 PM chinry: I bought it factory new
03:17 PM Fuchikoma: Doesn't really matter; there are no fuses that ar required to set up the SPI hardware. If you did that to set the main clock or whatever that's fine, but I'll assume that's working sine you didn't brick it
03:18 PM Fuchikoma: SPI freq is f/128?
03:19 PM chinry: yeah i set it the slowest possible speed
03:19 PM Fuchikoma: Why are you outputting to PORTB ? it's not immediately clear what that's about
03:21 PM chinry: setting the slave select
03:21 PM Fuchikoma: ah
03:21 PM chinry: i am planning on using pin 1 and 2 to select between slaves
03:22 PM Fuchikoma: That should be fine
03:23 PM chinry: I tested it with hardware and simavr and I am getting nothing from the data transfer. Do you happen to have a working example?
03:23 PM chinry: SCK does not output a clock
03:23 PM Fuchikoma: oh wait this is strange
03:24 PM Fuchikoma: ldi r17, (1<<DDB2)|(1<<DDB3)|(1<<DDB5)
03:24 PM Fuchikoma: Shouldn't that be 3,4,5 ?
03:24 PM chinry: Let me check
03:25 PM Fuchikoma: Setting the direction bits on pins 3,4,5 (MOSI, MISO and SCK) to output
03:25 PM chinry: I dont need MISO
03:25 PM chinry: do I still have to set it?
03:25 PM Fuchikoma: Still, though, it's best practice
03:25 PM chinry: ok
03:25 PM * Fuchikoma thinks
03:25 PM Fuchikoma: Input, MISO should be input
03:26 PM Fuchikoma: herp derp
03:26 PM chinry: oh yeah
03:26 PM Fuchikoma: The next thing to check is if there's anything messing with the bus external to the 328p. Are you using a scope or LA to look for a signal?
03:27 PM chinry: Yes. But shouldn't it still work in simavr?
03:28 PM chinry: I am using a digital scope
03:28 PM Fuchikoma: I never used simavr so I don't know
03:29 PM chinry: it gives me a vcd file after I simulate.
03:30 PM Fuchikoma: I just put it on the chip myself, rarely bother with simulators
03:32 PM Fuchikoma: If the interrupt bit is gettnig set then the device at least *thinks* it send the data, so either the pins are misconfigured or there's something external to the device that's messing with the bus
03:32 PM chinry: https://volafile.org/r/180h1kg2r
03:32 PM chinry: Ok
03:32 PM Fuchikoma: And if it's in a sim there's nothing to mess with the bus, I guess
03:33 PM chinry: Do you know of any working examples of assembly SPI. I've been searching for a while. I guess I can try looking disassembled c?
03:34 PM Fuchikoma: Off the top of my head there shold be an example in the datasheet
03:35 PM chinry: Yeah I've been toying with the assembly version. But I guess if I can get it to work in c I can look at what is actually happening.
03:37 PM Fuchikoma: I'm headed home; if you're still around in about an hour we can pick this up again; I might have something though I only ever rememberusing I2C
03:38 PM Fuchikoma: (But I do program everything in assembly so at least I'm helpful that way :) )
03:38 PM chinry: Ok, I'm taking a look at the fuses calculator in the topic just to double check that as well.
03:39 PM chinry: Thanks a bunch for your time.
11:20 PM day__ is now known as day