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.

  • In what way are they "not working"?

  • I get the error "This file should only be compiled by ARM IAR compiler and assembler" so it seems that is does not work with Keil uVision.

    I can compile with IAR Embedded Workbench, but I would like to use Keil uVision for the programming. Maybe there are somewhere other code examples? I cannot find them.. or a good header file with the register separated.

  • "I get the error 'This file should only be compiled by ARM IAR compiler and assembler'"

    If you have the files as source then, surely, that could only come from a #error directive?

    So part of your porting from IAR to Keil would be to adjust that!

    Keil's header file is available on the link you gave in your original post.

  • I couldn't see any TMS470-specific examples at http://www.keil.com/download/list/arm.htm

    TI seem to be in bed with IAR for this controller - there's no mention of Keil on their "TMS470 Third-Party Network" page: focus.ti.com/.../mcugeneralcontent.tsp

    So, the pragmatic approach would seem to be to go with IAR - at least while you gain basic familiarity with the chip...?

  • We have TMS470 support in the folder Keil\ARM\Boards\TI. Did you look to this examples?

  • Yes the error is coming from a #error handler. Here it is

    #if (((__TID__ >> 8) & 0x7F) != 0x4F) /* 0x4F = 79 dec */
    #error This file should only be compiled by ARM IAR compiler and assembler
    #endif

    but when I comment this code and try to compile it in Keil uVision I get the error message something like "The instruction at 0x00752533 is refering to memory address 0x00000030. The read-adaption on the memory has failed" something like that.. I get these message in dutch so maybe it's a bit different in english :) It's about this line in the header file iotms470r1a256.h

    /* ** ** System module control (SMC) **
    */

    __IO_REG32_BIT(SMCR0, 0xfffffd00,__READ_WRITE,__smcr0_bits);

    so I guess if I want to use these code examples I have to go with IAR like you said Neil.

    I saw the Blinky example in Keil\ARM\Boards\TI\ folder and I can compile that one but I am more looking for code examples of SPI and CAN. But maybe I can figure it out with the user manuael and the header file in the Blinky example. I guess there are no examples of these peripherals somewhere, working with uVision?

    Well thanks already.

  • 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.

  • 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.