#avr Logs

Sep 26 2021

#avr Calendar

03:27 PM guanche: Hi guys, do I have to enable interrupts to use SPI?
03:34 PM guanche: I'm doing this: `while (!(SPSR & (1 << SPIF));' not having called `sei ();', and it seems the atmega gets into an endless loop
03:37 PM guanche: the problem must be in the SPI code, because the rest of the functions in the protocol do answer back, I'm gonna paste my function
03:37 PM exp: i don't see anything that indicates interrupts are required
03:38 PM guanche: even calling `sei ();' on main gives the same result, so there's probably something wrong (I don't see) with my code
03:38 PM exp: the description of the module behaviour on page 170 of the datasheet indicates interrupts are generated after SPIF is set
03:38 PM exp: yeah sounds like it
03:38 PM exp: may i ask why you plan to have interrupts disabled?
03:39 PM guanche: https://pastebin.com/raw/0nYHGpNW
03:40 PM guanche: because I don't need them, I understand by the datasheet that interrupts will be called, if enabled
03:42 PM guanche: I ported this from a leonardo, which is the one I want to program (it seems I burnt the buffers on my avrispmkII), but I'm just testing the comunication protocol when I found the atmega seems to get into an endless loop
03:42 PM exp: i don't suppose you have probed the spi pins to check if the data you expect comes out?
03:42 PM guanche: the `clock_delay' function is not causing this, I have checked it through another command
03:43 PM guanche: not yet, because I'm trying to get the comunication between the atmega and the host working
03:43 PM guanche: which was supossed to be already
03:44 PM exp: well, the loop seems reasonable enough to my tired eyes, so i'd suspect something else isn't running properly, how's ~SS handled?
03:45 PM guanche: is not handled at all, and this code used to work in leonardo, I could read signatures, lock-bits, flash, etc
03:45 PM exp: the datasheet mentions that if configured as an input, it must be held high
03:46 PM exp: but regardless, SPIF should be set
03:46 PM guanche: how strange
03:46 PM guanche: I was doing isp to this same arduino
03:52 PM guanche: I'll chase it tomorrow, thanks exp for your time