This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Demo application TMS470

Hi,

I found some demo applications on the website of TI, but it seems that those aren't working in Keil uVision, or with the headerfile I can download from the Keil site located here: http://www.keil.com/dd/chip/4070.htm

I was wondering if I can find somewhere any demo codes, like GPIO, CAN and SPI for this microcontroller using Keil uVision. Does anyone here has some demo code/examples available?

Thanks a lot.

Parents
  • Please read the instructions on how to post source code!
    www.danlhenry.com/.../keil_code.png

    "when I comment this code and try to compile it in Keil uVision I get the error..."

    That should come as no surprise!

    Of course you can't just comment it out!

    IAR (most likely) didn't put it there just to be spiteful - they put it there because they know that the code relies upon some specific feature(s) of their implementation.
    Therefore, if you want to make it work with Keil, you are going to have to port it - that is, adapt it to the specifics of Keil.

    That requires an understanding of both the IAR tools and the Keil tools - probably also the chip itself.

    You can't simply comment-out the bit that is telling you that it won't work with another compiler!

    "if I want to use these code examples I have to go with IAR"

    If you want to use IAR's examples without modification then, yes; of course you will need to use IAR - just as if you wanted to use Keil's examples without modification you'd have to stick with Keil.

Reply
  • Please read the instructions on how to post source code!
    www.danlhenry.com/.../keil_code.png

    "when I comment this code and try to compile it in Keil uVision I get the error..."

    That should come as no surprise!

    Of course you can't just comment it out!

    IAR (most likely) didn't put it there just to be spiteful - they put it there because they know that the code relies upon some specific feature(s) of their implementation.
    Therefore, if you want to make it work with Keil, you are going to have to port it - that is, adapt it to the specifics of Keil.

    That requires an understanding of both the IAR tools and the Keil tools - probably also the chip itself.

    You can't simply comment-out the bit that is telling you that it won't work with another compiler!

    "if I want to use these code examples I have to go with IAR"

    If you want to use IAR's examples without modification then, yes; of course you will need to use IAR - just as if you wanted to use Keil's examples without modification you'd have to stick with Keil.

Children
  • IAR has most likely an header file that defines a macro or inline function for __IO_REG32_BIT.

  • "I saw the Blinky example in Keil\ARM\Boards\TI\ folder and I can compile that one.."

    Great - so now you have a working framework for a Keil application!
    Use this as the basis for future work...

    "but I am more looking for code examples of SPI and CAN."

    So, one step at a time, start bringing that functionality into your Keil application.

    Use the IAR examples to guide you - just don't expect them to compile & run directly without modification under Keil!

  • And also for __TID__ - and the #if is there to ensure that it is appropriately defined!

    As should be expected, if __TID__ is not appropriately defined, it doesn't work!

    So, what you need to do is to provide an appropriate definition for __TID__ - not just remove the test that checks for it!

    And all the other definitions...

  • The Reinhard is right the IAR header has defined all registers by macro __IO_REGS32_BIT which is as follows:

    #define __IO_REG32_BIT(NAME,ADDRESS,ATTRIBUTE,IT_STRUCT)\ 
                         volatile __no_init ATTRIBUTE union \ 
                          {                                 \ 
                            unsigned long NAME;             \ 
                              BIT_STRUCT NAME ## _bit;      \ 
                          } @ ADDRESS;
    

    this macro can not be used in Keil (ARM) tools as it uses IAR specific directives and names like _bit, @ .

    So, you can not include IAR's header directly, we at Keil already have register definition header file which is in folder Keil\ARM\INC\TI\TMS470R1.h which is prepared for Keil tools.

    So the code from IAR can not be directly included and built with Keil tools as some things are done differently.

    My suggestion is to use Keils Blinky from folder Keil\ARM\Boards\TI\TMS470R1B1M\Blinky as a template and then build on it.

    You can take IAR's .c source file for example for CAN setting and you can change register accesses in it for example

     PCR = CLKDIV_2;
    

    would for Keil be written as

     pSM->PCR = CLKDIV_2;
    

    but also tms470r1b1m_bit_definitions.h from IAR would have to be included for constants values.

    Other way is that you make your own include file where registers would have to be defined like this:

    #define PCR (*(volatile unsigned long *)(0xFFFFFD30))
    

    but also tms470r1b1m_bit_definitions.h from IAR would have to be included for constants values.

  • Thanks so far. I did try some coding in the Blinky example and it seems to work. I guess I can code the CAN and SPI peripherals with it using the User Manual of TI.

    Will try and see if I can use some of the examples available for IAR or else I will program it all by myself.