Hot!Porting to XC16

Author
naeem1234
Super Member
  • Total Posts : 449
  • Reward points : 0
  • Joined: 2015/02/19 06:39:28
  • Location: 0
  • Status: offline
2018/10/12 00:29:06 (permalink)
0

Porting to XC16

Hello everyone
 
I need to port the following code which is written in some other compiler to XC16.
sbit TEST_1 at RB7_bit;
sbit TEST_2 at RB8_bit;
sbit TEST_3 at RB9_bit;

 
Your help is highly appreciated.
#1

10 Replies Related Threads

    crosland
    Super Member
    • Total Posts : 1331
    • Reward points : 0
    • Joined: 2005/05/10 10:55:05
    • Location: Bucks, UK
    • Status: offline
    Re: Porting to XC16 2018/10/12 01:13:28 (permalink)
    +1 (1)
    Which other compiler?
     
    What does the code do? We don't have a crystal ball.
     
    It looks like the code is declaring bits in PORTB.
     
    First of all read the XC16 documentation. Does it support 'bit' types?
     
    If it does, then refer to the section that explains how to declare and use them.
     
    If not, you need to consider a different strategy. What that strategy might be I can't say, without knowing more about the application.
     
     
    #2
    Chris A
    Super Member
    • Total Posts : 807
    • Reward points : 0
    • Joined: 2010/07/20 04:37:07
    • Location: 0
    • Status: offline
    Re: Porting to XC16 2018/10/12 03:51:51 (permalink)
    0
    I would guess that the following may allow the rest of the code to stay the same.
    #define TEST_1 PORTBbits.RB7
    #define TEST_2 PORTBbits.RB8
    #define TEST_3 PORTBbits.RB9

     
    You will also need to include the correct header.
    #3
    qhb
    Superb Member
    • Total Posts : 7919
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: online
    Re: Porting to XC16 2018/10/12 04:03:02 (permalink)
    +1 (1)
    So long as the pins are being used for input, not output.
    #4
    crosland
    Super Member
    • Total Posts : 1331
    • Reward points : 0
    • Joined: 2005/05/10 10:55:05
    • Location: Bucks, UK
    • Status: offline
    Re: Porting to XC16 2018/10/12 04:53:03 (permalink)
    0
    qhb
    So long as the pins are being used for input, not output.


    Like I said, we need to know more than the OP is telling us.
    #5
    naeem1234
    Super Member
    • Total Posts : 449
    • Reward points : 0
    • Joined: 2015/02/19 06:39:28
    • Location: 0
    • Status: offline
    Re: Porting to XC16 2018/10/14 10:03:36 (permalink)
    0
    The code that I am porting has used following 'org' keyword in it.
     

    void TIMER2_INT() org 0x0022
    {..}
     
    void TIMER5_INT() org 0x004C
    {..}
     
    void CN_INT() org 0x003A
    {..}

     
    Is there any simpler and better way to do as above?
    #6
    MBedder
    Circuit breaker
    • Total Posts : 6559
    • Reward points : 0
    • Joined: 2008/05/30 11:24:01
    • Location: Zelenograd, Russia
    • Status: offline
    Re: Porting to XC16 2018/10/14 11:07:21 (permalink)
    0
    The compiler which ORGs the ISRs seems to me a bit crazy, albeit this approach allows using no linker script to primitivise the coding. What is that compiler's name/brand?
    #7
    qhb
    Superb Member
    • Total Posts : 7919
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: online
    Re: Porting to XC16 2018/10/14 12:20:16 (permalink)
    0
    As above.
    If you have to port all these non-standard constructs, then you have to reveal what compiler is using them so people can suggest correct alternatives.
     
    #8
    MBedder
    Circuit breaker
    • Total Posts : 6559
    • Reward points : 0
    • Joined: 2008/05/30 11:24:01
    • Location: Zelenograd, Russia
    • Status: offline
    Re: Porting to XC16 2018/10/14 12:27:35 (permalink)
    0
    Actually I'm aware of just a couple third party dsPIC compilers - CCS and MicroC. Which one is yours?
    #9
    JPortici
    Super Member
    • Total Posts : 454
    • Reward points : 0
    • Joined: 2012/11/17 06:27:45
    • Location: Grappaland
    • Status: offline
    Re: Porting to XC16 2018/10/14 13:29:00 (permalink)
    0
    sbit TEST_1 at RB7_bit;

    makes me wonder if you were using mikro C for dsPIC.
    use the "define" method suggested above.
     
    As for those which are clearly interrupt routines, XC16 will init the vector atuomatically if you use the builtin names for ISRs, such as
    void __attribute__((interrupt)) _T2Interrupt()

     
    I suggest you read both manuals, XC16's the one for your other compiler and adapt things accordingly
    #10
    naeem1234
    Super Member
    • Total Posts : 449
    • Reward points : 0
    • Joined: 2015/02/19 06:39:28
    • Location: 0
    • Status: offline
    Re: Porting to XC16 2018/10/14 21:08:00 (permalink)
    0
    Jack_M
    sbit TEST_1 at RB7_bit;

    makes me wonder if you were using mikro C for dsPIC.
    use the "define" method suggested above.
     
    As for those which are clearly interrupt routines, XC16 will init the vector atuomatically if you use the builtin names for ISRs, such as
    void __attribute__((interrupt)) _T2Interrupt()

     
    I suggest you read both manuals, XC16's the one for your other compiler and adapt things accordingly




    Thanks a lot.
    I am not 100% sure but most probably the other compiler is micro-C.
    #11
    Jump to:
    © 2018 APG vNext Commercial Version 4.5