#avr Logs

Apr 26 2020

#avr Calendar

02:57 PM giantmidget: test
03:03 PM giantmidget: Anyone here lads?
04:45 PM giantmidget: fucking rup
04:45 PM giantmidget: rip
04:50 PM PoppaVic: nope
04:58 PM learath: Only regular RIP :)
05:02 PM giantmidget: :P
05:02 PM giantmidget: Hey lads, I'm having an issue with SPI on an STM32
05:03 PM giantmidget: When I attempt to send 8 bits I get two consecutive 8 bit transmissions
05:09 PM soreau: How are you sending the bits and how are you observing two transmissions?
05:10 PM soreau: also, are the transmitted bytes duplicated?
05:20 PM giantmidget: No - the first transmission is the correct byte and the second is a null byte
05:21 PM giantmidget: Logic Analyzer
05:21 PM giantmidget: I'll link the code 1 sec
05:24 PM soreau: maybe you have to set SPI_IOC_WR_BITS_PER_WORD or something
05:34 PM soreau: or some bug in your code
05:40 PM giantmidget: https://gist.github.com/keshakot/6cf070110bf6d02cfcdbfbb7b89ed2c8
05:40 PM giantmidget: Sorry that took a little while
05:42 PM giantmidget: It is most likely an issue in how I configured the SPI interface, but I'm not sure what it is
05:43 PM giantmidget: I seem to have set packet size to 8 bits (lines 88, 89, and 99)
05:44 PM giantmidget: It's as if it's reading out the entire data register
05:47 PM soreau: so you're calling SPI_Write() with len = 1?
05:48 PM giantmidget: That is correct
05:48 PM giantmidget: Lines 120 and 121 should be uncommented, but it makes no difference
05:55 PM soreau: giantmidget: I think you might need to do something like https://github.com/espruino/Espruino/blob/master/targetlibs/stm32f4/lib/stm32f4xx_spi.c#L598
06:00 PM soreau: I think you need to unset these bits https://github.com/LonelyWolf/stm32/blob/master/ls027b7dh01/periph/spi.h#L79
06:01 PM soreau: because #define SPI_CR2_DS ((uint32_t)0x00000F00)
06:02 PM giantmidget: To clarify I'm using an STM32F030 - the first link you sent me is for the F4 - the CR1's are different for these chips, so that will not woirk
06:02 PM soreau: well the idea is that you might not be unsetting the right bits
06:03 PM soreau: but the more I look at it, it seems like you are
06:03 PM soreau: just make sure to triple check that part
06:03 PM giantmidget: Yes I am - I have confirmed this through the debugger as well
06:05 PM giantmidget: The packet being sent is an 8 bit packet - it's just that there's two of them being sent whenever I try and send one - the SS and SCK lines go high between these packets
06:06 PM soreau: giantmidget: maybe https://www.eevblog.com/forum/microcontrollers/stm32f0-spi-8bit-communication-frame-(errata)/msg301971/?PHPSESSID=ktv46fdvjnhls4agtgr0ris7u6#msg301971
06:06 PM soreau: but that's so old, I'd hope that would be fixed in whatever code you're using
06:08 PM soreau: there's some other interesting tidbits in that thread though
06:08 PM giantmidget: hmm - seems like my problem, yes
06:11 PM soreau: giantmidget: but some are saying that you have to make a pointer to DS of *uint8_t and write to that
06:11 PM soreau: instead of writing DS directly
06:11 PM giantmidget: let me try that
06:12 PM soreau: giantmidget: https://pastebin.com/DYMSbXfh
06:15 PM soreau: well my code is flawed, I didn't deref the pointer on assignment
06:15 PM soreau: there https://pastebin.com/W82X2Gei
06:20 PM soreau: wait that's still not right
06:20 PM soreau: there https://pastebin.com/rEpTthwx
06:39 PM giantmidget: Sorry mate was getting some breakfast - that actually worked :P
06:40 PM soreau: oh yea baby
06:40 PM soreau: you can also use *(uint8_t *)SPI->DR = data;
06:43 PM giantmidget: Yeah that'll work too
06:43 PM giantmidget: interesting issue lol
06:43 PM soreau: I guess it kinda makes sense.. it's just the way it works
06:44 PM soreau: now off you are to solve other interesting problems ;)
06:47 PM giantmidget: That I am - and thanks a lot for your help!
06:47 PM soreau: No problem
11:31 PM day_ is now known as day