Skip to main content
Visitor II
August 6, 2021
Solved

Can I use assembly command "mov" to move data from peripheral to peripheral ?

  • August 6, 2021
  • 2 replies
  • 1560 views

I'm currently using the STM8L151F3 and implementing the SUMP open logic analyzer. In one part of my code involving with GPIO reading and send data to SPI1_DR. and to make a lots of the capture samples, I use the F-RAM as a external RAM for sampling memory. Since the F-RAM is really fast and practically almost no delay (SPI running at 8MHz).

My question is can I use "mov" instruction to "copy" data from one peripheral address to another ?

this part taken from my code at line 231.

https://github.com/TiNredmc/stm8l_sdcc_template/blob/master/code/ComeNCapture/main.c#L231

// Notice : SDCC compiler 
do{
__asm___("mov 0x5204, 0x5006");// PB_IDR -> SPI1_DR
while(capture){

    This topic has been closed for replies.
    Best answer by Cristian Gyorgy

    Hi!

    Yes, you can. Just pay attention to what peripheral location you write, not all are writable of directly accessible, and there are also reserved bits.

    In your case, pay attention if you want to verify this you cannot do it by reading the value you wrote, because you would actually read the SPI data input register.

    Good byte!

    2 replies

    Visitor II
    August 6, 2021

    Hi!

    Yes, you can. Just pay attention to what peripheral location you write, not all are writable of directly accessible, and there are also reserved bits.

    In your case, pay attention if you want to verify this you cannot do it by reading the value you wrote, because you would actually read the SPI data input register.

    Good byte!

    TinLethaxAuthor
    Visitor II
    August 6, 2021

    So, using "mov" will actually read the GPIO input (PortB in this case) and copy over to the SPI data register and the the SPI hardware do their own tx job. Is that correct ?

    Visitor II
    August 6, 2021

    Yes.

    TinLethaxAuthor
    Visitor II
    August 6, 2021

    Oh great, thank you.