How do I read the output of the COMP block for a TI C2000 processor?

6 views (last 30 days)
I would like to read the output for the COMP (Comparator) block for a TI C2000 processor, such that I can use the value inside my model. The COMP block outputs to the GPIO1 pin, as specified in 'Configuration Parameters > Hardware Implementation > Target hardware resources > COMP', but I am not able to access this value.
I have tried doing this by using the GPIO Digital Input block, but I get the following error:
Error evaluating 'InitFcn' callback of C280x GPIO Digital Input block (mask) 'Comparator/Digital Input'.
Callback string is 'validateC280xGPIO;'
Caused by:
The GPIO pin GPIO1 is already used by another block.
What other block should I be using?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 16 Apr 2019
Edited: MathWorks Support Team on 16 Apr 2019
According to the documentation, which you can find on the following page:
this block should be used to configure the pin, the sample time, and the data type for analog input. Thus, in the current configuration, Simulink tries to configure the pin 'CPIO1' to receive input from an external source. However, this pin is already assigned to the output of COMP, and thus it gives an error.
The block that can be used in this scenario is the Memory Copy block:
which you can find in the Simulink Library Explorer under 'Embedded Coder Support Package for Texas Instruments C2000 Processors > Memory Operations'. In this case, you should configure the block as in the attached image (block_config.PNG). Thus, the settings you should change are the following:
  • 'Source > Copy from:' set to 'Specified source code symbol'
  • 'Source code symbol' set to '&GpioDataRegs.GPADAT.all'
  • 'Data type:' set to the desired type, such as boolean or uint32
This block will provide the register containing the GPIO pin states. You can then extract the required GPIO from the output.
You can find an example application of this block, by running the following command in the MATLAB Command Window:
>> c28035pmsmfocdual
The Memory Copy block can be found inside 'Hall Sensor B': the block is called 'ECap1Regs.TSCTR'.

More Answers (0)

Products


Release

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!