This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2640R2F: Sensor Controller Studio assembly workflow

Part Number: CC2640R2F

Hi,

I am implementing some timing-critical functions on the Sensor Controller which need to be coded in assembly. I have managed to integrate this in the C Execution Code by implementing a custom resource definition and procedure definition (resource_def, proc_def) and accessing with a function call. This works but I have found the workflow a bit torturous and I also have some questions around the assembly language reference itself.

The first thing is that edits in the procedure definition can only be picked up by restarting Sensor Controller Studio. I have tried disable/enable of the resource, close and reload the project,etc., but only a complete restart recognises changes in the .prd file leading to a very long code/compile cycle. Is there any way to get SCS to re-read the proc_defs without a restart? I am using the latest (2.4.0.793) version of the software.

Regarding the assembly reference, it is clear that certain instructions set/reset flags and that these flags are used in subsequent branches to direct program flow. It is not made explicit how these flags are set, however. Taking the example of the right-shift (lsr) operation which modifies the Z,N,C flags, I assume the following:

  • Z is set if Rd == 0x0000 after the shift
  • N is set if Rd == 0b1xx...xxx after the shift
  • C is set if Rd == 0bxxx...xx1 before the shift

If this is correct then shifts between words (registers) would be possible without a test instruction by branching on the carry condition - is this the case?

A final question is around flags being used by the instructions. It seems that instructions apart from branch (b<cc>) only set flags and do not change operation based on flag state. Is this correct, i.e. there is nothing like an add-with-carry for example?

Regards,

Jamie

  • Hi Jamie,

    trackert said:

    The first thing is that edits in the procedure definition can only be picked up by restarting Sensor Controller Studio. I have tried disable/enable of the resource, close and reload the project,etc., but only a complete restart recognises changes in the .prd file leading to a very long code/compile cycle. Is there any way to get SCS to re-read the proc_defs without a restart? I am using the latest (2.4.0.793) version of the software.

    *.prd files are only read at SCS startup and *.asm files are read at every code generation. I'll provide your feedback to the tools team.

    trackert said:

    Regarding the assembly reference, it is clear that certain instructions set/reset flags and that these flags are used in subsequent branches to direct program flow. It is not made explicit how these flags are set, however. Taking the example of the right-shift (lsr) operation which modifies the Z,N,C flags, I assume the following:

    • Z is set if Rd == 0x0000 after the shift
    • N is set if Rd == 0b1xx...xxx after the shift
    • C is set if Rd == 0bxxx...xx1 before the shift

    If this is correct then shifts between words (registers) would be possible without a test instruction by branching on the carry condition - is this the case?

    This is correct.

    trackert said:

    A final question is around flags being used by the instructions. It seems that instructions apart from branch (b<cc>) only set flags and do not change operation based on flag state. Is this correct, i.e. there is nothing like an add-with-carry for example?

    There is no "add with carry" instruction. CC26x2R have a MAC-module that simplifies calculation with bigger numbers. On CC2640R2 you'll need to do a b<cc>-instruction and one extra add-instruction.

    Best regards,
    Simon

  • Hi Simon,

    Thanks for the quick response. If I understand correctly I may be able to compile the assembly without restarting the IDE by putting in an .asm file and linking from the .prd?

    It looks like this removes the option of dynamic register allocation (RS{temp}) but I can probably live with that.

    Best Regards,
    Jamie
  • Hi Jamie,

    Correct. Take a look at for example gpio_get_input_value.prd and gpio_cfg_mode.prd to see how this is done. Notice the "internal" tags and "ref" dummy instructions.

    Best regards,
    Simon
  • Will do, thanks for your help Simon.

    Best Regards,

    Jamie