Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Apr 20 01:51
    esden commented #2
  • Apr 20 01:50

    esden on master

    Update to recent libopencm3 (compare)

  • Apr 20 01:50
    esden closed #2
  • Jan 04 00:37
    schodet opened #2
  • Oct 20 2021 08:57
    tommcq opened #17
  • Jun 19 2021 05:58

    esden on master

    Updated LOCM3. Improved the clean target. Ignore if st-link/dfu-util is n… and 9 more (compare)

  • Aug 05 2020 21:27

    0xdec on v2.0a

    More WIP (compare)

  • Jul 31 2020 21:36

    0xdec on v2.0a

    WIP migration + v2.0a (compare)

  • Nov 06 2018 16:29
    esden commented #16
  • Nov 06 2018 16:28

    esden on master

    Fix formatting, typos, grammar … (compare)

  • Nov 06 2018 16:28
    esden closed #16
  • Nov 06 2018 03:42
    0xdec opened #16
  • Oct 21 2018 20:53
    Poofjunior opened #15
  • Oct 12 2018 05:48
    frankalicious closed #10
  • Aug 24 2018 22:49
    irandms opened #5
  • Aug 22 2018 11:38
    elektor-labs edited #14
  • Aug 22 2018 11:36
    elektor-labs opened #14
  • May 24 2018 12:17

    kbob on master

    Improve audio clock calculation. Experiment with different color… Added bit definitions for the g… and 1 more (compare)

  • Apr 23 2018 12:45
    RandoSY edited #13
  • Apr 23 2018 12:44
    RandoSY edited #13
Luke Beno
@lgbeno
is there a reference for using the libopencm3 SPI2 abstraction

So far this is what I'm trying

static void spi_setup(void) {
    /* INIT SPI GPIO */
    gpio_mode_setup(GPIOB, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO13|GPIO14|GPIO15);
    gpio_set_af(GPIOB, GPIO_AF5, GPIO13|GPIO14|GPIO15);

    /* INIT SPI SS GPIO */
    gpio_mode_setup(GPIOB, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO12);
    gpio_set(GPIOB, GPIO12);

    spi_set_master_mode(SPI2);
    spi_set_baudrate_prescaler(SPI2, SPI_CR1_BR_FPCLK_DIV_64);
    spi_set_clock_polarity_0(SPI2);
    spi_set_clock_phase_0(SPI2);
    spi_set_full_duplex_mode(SPI2);
    spi_send_msb_first(SPI2);
    spi_set_nss_high(SPI2);
    spi_enable(SPI2);

}

Then in main, I will do:

spi_send(SPI2, 0xDE);
spi_send(SPI2, 0xAD);
spi_send(SPI2, 0xBE);
spi_send(SPI2, 0xEF);
Luke Beno
@lgbeno
I also have the
rcc_periph_clock_enable(RCC_SPI2);
Luke Beno
@lgbeno
ok, I found a better example in the comments of the libopencm3 code https://github.com/libopencm3/libopencm3/blob/master/lib/stm32/common/spi_common_all.c#L22
Bits are now twiddling!
Chuck McManis
@ChuckM
@lgbeno also note that if you use spi_xfer rather than spi_send then it will return once the byte has been completely sent. This can be important in controlling displays where they want you to send the control byte first, then set a pin to indicate data, and send data bytes next.
Luke Beno
@lgbeno
Thanks
reading the docs between the two, it looks like xfer also reads back at the same time as write
although _send says that it blocks as well although not sure that this is true
right now with my current config, I can only get the port to work at 20MHz, (despite trying to config for 1MHz) need to slow it down for the chip that I want to talk to
Chuck McManis
@ChuckM
It is the way SPI works, it always clocks in a byte at the same time it clocks out a byte. But the peripheral is double buffered, so if you tell it to send it will put the byte in the transmit buffer and start sending. The next time you tell it to send it will put the byte into the double buffer and return. And the third time you send it will wait for the first one to finish, the second one to get transferred over to the xmit buffer, and then put the byte into the double buffer and return.

A number of people have run into issues when their code does

    uint8_t *cmd_buf;
   spi_send(*cmd_buf++);
   gpio_set(<pin to set data/command line>);
  spi_send(*cmd_buf++);
 ...
  gpio_clear(<pin to set data/command>);

That ends up setting the command/data line about 3 or 4 bits into the first transmission and often confuses the heck out of an SPI driven display.

Keith Legg
@keithlegg
I have a working SPI and I2C example I cooked up if anyone wants them. I wish the example projects came with some more basic examples like these. It was a good learning experience to write them both
Amitesh Singh
@amitesh-singh
Spi send funtion does wait for previous transfer to.complete before writing to data register.
Spi_write function does not wait.
SPI_DR(SPI1) = data;
Amitesh Singh
@amitesh-singh
Chuck, is this the case with stm32? Or any spi interface irrespective of mcu.
Chuck McManis
@ChuckM
@amitesh-singh it is a the case with the version of the SPI interface on the chip used on the 1BitSy. ST has an older interface that was used on some earlier (like the old F1 chips) that is a bit different in some ways. All of the 'new' versions have support for the automatic control of NSS or "multi-master" support.
Amitesh Singh
@amitesh-singh
@ChuckM aha, good to know. thanks
Amitesh Singh
@amitesh-singh
i have noted it down. i think i have faced weird behaviour on stm32f1's SPI before. i did not know that this was the reason.
@ChuckM "It is the way SPI works, it always clocks in a byte at the same time it clocks out a byte." -> this is what i have known from AVR experience.
Chuck McManis
@ChuckM
@amitesh-singh well the challenge is that SPI has a very limited "specification" which was intentional to make it easy to implement in just a few gates on a microprocessor. As a result you have hardware versions with varying levels of sophistication. Apparently the F7's version is more sophisticated still but I haven't had a chance to dig into that one yet.
Piotr Esden-Tempski
Embedded Programming with Black Magic and the Lights On
Sunday 13:45 - 15:45 | Supplyframe HQ LA time
Piotr Esden-Tempski
@esden
:D
Chuck McManis
@ChuckM
@esden are you around the 'office' Sunday? I'm driving up to Portland from the Bay Area
Piotr Esden-Tempski
@esden
John Whitmore
@johnfwhitmore
I'm looking at the datasheet for the STM32F415xx and it's not the datasheet I'm looking for? I'd assumed that the datasheet, DocID022063, was what I was looking for but it has an overview of the various timers. Not the config registers and how they should be configured. Perhaps I'm missing something but all I can find is that datasheet and not a programming guide. Is there a programmers guide? Should I be looking for an M4 programming guide? I'd assumed that the timers etc were bolted on to the M4 by STM and not part of that manual?
John Whitmore
@johnfwhitmore
Nope that document I listed, the M4-Programming manual only deals with the core peripherals. So still searching for a document
John Whitmore
@johnfwhitmore
@AvianAmbassador_twitter - OMG if what I'm looking for isn't in a 1745 Page document. Thanks a million for that it's exactly what I'm looking for ;-)
Paul Fernquist
@PaulF8080
Be careful. I read the Ethernet section and later found out the chip model doesn't have that subsystem.
John Whitmore
@johnfwhitmore
I'm only on the basics of general timers so I should be OK for the time being. But thanks for the warning. I'll keep that in mind for future.
John Whitmore
@johnfwhitmore
Can the gdb debugger set a break point in an Interrupt routine?
Just trying to confirm that I'm getting into my Timer2 ISR and clearing the flag. gdb isn't getting to a breakpoint, but my LED is on suggesting it got in there.
John Whitmore
@johnfwhitmore
Forget that I forget that there's pullup on the LED. Ain't getting to the ISR.
John Whitmore
@johnfwhitmore
There's obviously not a great deal of traffic on this channel, so probably not the best place to post, however... About a week ago I added an example to the 1bitsy-examples project of using Timer2 to flash the on board LED. I was sure I'd created a pull request for my additions on github. I can't see any record of that pull request. I'm not sure it wasn't just dumped, in which case there's no point in my re-trying, or if I actually made a mistake in my attempted pull request, so it never happened. Anybody official got their ears on here?
HooperFly
@hooperfly
@johnfwhitmore ping @esden. He can probably help you with that.
John Whitmore
@johnfwhitmore
Thanks
Premature send. That sounded a bit abrupt. Thanks for that HooperFly, I'll try give @esden a shout.
Piotr Esden-Tempski
@esden
@johnfwhitmore I don't think I have seen a pull request from you regarding timer ... I will check in a sec
you might have sent the pull request to the wrong repository
it happens sometimes when you create a pull request on github that the dropdown by default points to the wrong destination
You have the patch you are mentioning in your repository here: https://github.com/johnfwhitmore/1bitsy-examples/commits/master
you should have feature branches this makes things easier especially if changes are needed before your patch can be merged up stream
Anyways thank you for making a new patch and trying to send it our way that is always very appreciated. The flow needs some learning but it is at the end very efficient on the maintainer side of things if done right. :)
Thanks!