• AVR Freaks

Hot!switch case problem in mplabx ide v5.15

Page: 12 > Showing page 1 of 2
Author
prasanth R
Starting Member
  • Total Posts : 60
  • Reward points : 0
  • Joined: 2017/01/10 04:46:37
  • Location: 0
  • Status: offline
2019/03/14 23:54:14 (permalink)
0

switch case problem in mplabx ide v5.15

Dear all,
        I'm using mplabx v5.15 to program my controller. I tried to use simple switch case code to my controller. But while debugging our cursor not moved inside of switch statement even the statement variable getting matched.
     I used this same code at MPLABX v4.10. But its not working in the current IDE. Please assist me to solve this issue.
 
Thanks & Regards,
Prasanth. 
#1

20 Replies Related Threads

    qhb
    Superb Member
    • Total Posts : 9998
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: switch case problem in mplabx ide v5.15 2019/03/15 00:56:28 (permalink)
    +1 (1)
    You left out the most important details.
    What PIC chip are you using?
    Which compiler are you using?
    Please show us the code you are testing with. Possibly the exact lines you are trying to step over have been optimised away.
     
     

    Nearly there...
    #2
    prasanth R
    Starting Member
    • Total Posts : 60
    • Reward points : 0
    • Joined: 2017/01/10 04:46:37
    • Location: 0
    • Status: offline
    Re: switch case problem in mplabx ide v5.15 2019/03/16 04:37:40 (permalink)
    0
    Sorry for ignore those details.
    My controller is pic18f26k40.
    compiler is xc8 v2.05.
    I attached a screenshot to it for your reference.
     
    Thanks & Regards,
    Prasanth.

    Attachment(s)

    Attachments are not available: Download requirements not met
    #3
    1and0
    Access is Denied
    • Total Posts : 9314
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: switch case problem in mplabx ide v5.15 2019/03/16 17:43:45 (permalink)
    +1 (1)
    prasanth R
    I attached a screenshot to it for your reference.

    You better post more of the code than that. ;)
     
    Edit: The lines
    TCPResponse[0]=<case value>; // Command code

    in the switch() case statements seem redundant.
     
    post edited by 1and0 - 2019/03/16 17:47:19
    #4
    prasanth R
    Starting Member
    • Total Posts : 60
    • Reward points : 0
    • Joined: 2017/01/10 04:46:37
    • Location: 0
    • Status: offline
    Re: switch case problem in mplabx ide v5.15 2019/03/18 20:58:19 (permalink)
    0
    I tried to pass the "TCPResponse[0]" variable to switch case but that also not working.
    The macros which are used inside of the switch case are available at "CommandCodes.h" file.
    That header file contents are
    #define HA_STATUS_READ       1
    #define HA_STATUS_WRITE      2
    #define HA_SOCKET_RESET      3
    #define HA_BOARD_RESET       4
    #define HA_NO_OF_USERS       5
    I attached that source file for your reference. 
     
    Thanks & Regards,
    Prasanth.

    Attachment(s)

    Attachments are not available: Download requirements not met
    #5
    qhb
    Superb Member
    • Total Posts : 9998
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: switch case problem in mplabx ide v5.15 2019/03/18 21:12:21 (permalink)
    +1 (1)
    You're still being a bit vague about what "Not working" means exactly.
    Sayign what you pressed, and what you saw, would give us a better idea of what you are doing.
     
    The compiler may well be smart enough to detect that the first line of each case statement is redundant, as already noted.
     

    Nearly there...
    #6
    prasanth R
    Starting Member
    • Total Posts : 60
    • Reward points : 0
    • Joined: 2017/01/10 04:46:37
    • Location: 0
    • Status: offline
    Re: switch case problem in mplabx ide v5.15 2019/03/18 21:30:20 (permalink)
    0
    TCPResponse[0] is just a character array. Actually what happens is that switch case is not working after reach that switch(LC_CommandCode) it goes out from the switch case even it didn't goes to default condition. Is it any problem in that switch case?
     
    Thanks & Regards,
    Prasanth.
    #7
    qhb
    Superb Member
    • Total Posts : 9998
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: switch case problem in mplabx ide v5.15 2019/03/18 21:42:15 (permalink)
    +1 (1)
    That still does not tell us what happens when you single step over the switch statement.
    Where does it go?
     

    Nearly there...
    #8
    prasanth R
    Starting Member
    • Total Posts : 60
    • Reward points : 0
    • Joined: 2017/01/10 04:46:37
    • Location: 0
    • Status: offline
    Re: switch case problem in mplabx ide v5.15 2019/03/18 21:56:52 (permalink)
    0
    It goes outside(end of switch case curly brace) from switch case.
    #9
    qhb
    Superb Member
    • Total Posts : 9998
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: switch case problem in mplabx ide v5.15 2019/03/18 21:59:43 (permalink)
    +1 (1)
    Have you tried switching to the disassembly window while stepping?
     

    Nearly there...
    #10
    NKurzman
    A Guy on the Net
    • Total Posts : 17504
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: switch case problem in mplabx ide v5.15 2019/03/18 23:13:16 (permalink)
    +1 (1)
    Welcome to optimization and the debugger.
    The code must execute correctly. Not jump the way you think it should. The question is is it doing the correct things.
    #11
    prasanth R
    Starting Member
    • Total Posts : 60
    • Reward points : 0
    • Joined: 2017/01/10 04:46:37
    • Location: 0
    • Status: offline
    Re: switch case problem in mplabx ide v5.15 2019/03/19 01:29:10 (permalink)
    0
    Dear qhb,
       I didn't tried disassembly window yet.
    #12
    prasanth R
    Starting Member
    • Total Posts : 60
    • Reward points : 0
    • Joined: 2017/01/10 04:46:37
    • Location: 0
    • Status: offline
    Re: switch case problem in mplabx ide v5.15 2019/03/19 01:32:12 (permalink)
    0
    Dear NKurzman,
         I also don't know why its working link this. I tried that same code at older version of IDE and compiler that was working fine but not know.
     
    #13
    qhb
    Superb Member
    • Total Posts : 9998
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: switch case problem in mplabx ide v5.15 2019/03/19 01:46:26 (permalink)
    +1 (1)
    prasanth R
    Dear qhb,
       I didn't tried disassembly window yet.


    So. Try it.
     
    Possibly you were using a lower optimisation value previously.

    Nearly there...
    #14
    prasanth R
    Starting Member
    • Total Posts : 60
    • Reward points : 0
    • Joined: 2017/01/10 04:46:37
    • Location: 0
    • Status: offline
    Re: switch case problem in mplabx ide v5.15 2019/03/19 01:49:39 (permalink)
    0
    Ok. I will try and update the result
    #15
    prasanth R
    Starting Member
    • Total Posts : 60
    • Reward points : 0
    • Joined: 2017/01/10 04:46:37
    • Location: 0
    • Status: offline
    Re: switch case problem in mplabx ide v5.15 2019/03/19 23:42:42 (permalink)
    0
    Dear qhb,
            Switch case is working fine. Actually i misunderstood while debugging that code. while debugging cursor goes inside of corresponding switch case after it reached the end of switch case curly brace. So when it goes to end of switch case curly brace i thought compiler goes out from switch case and at that time breakpoint also not worked. So its totally my misunderstanding. 
            Sorry for wasting your time and thanks a lot for your suggestions.
            I had one more doubt. We are using pic16f1936. If we taken out this for production to protect our hex file enabling "Code Protection" only enough or need to do any other protections?
     
    Thanks & Regards,
    Prasanth.
    #16
    Aussie Susan
    Super Member
    • Total Posts : 3590
    • Reward points : 0
    • Joined: 2008/08/18 22:20:40
    • Location: Melbourne, Australia
    • Status: offline
    Re: switch case problem in mplabx ide v5.15 2019/03/20 17:53:35 (permalink)
    +1 (1)
    You said in post #2 that you were using a PIC18F26K40 and in Post #16 that it is a PIC16F1936! Which is it or is this a different question altogether?
    As for how the Code Protection works, check out Section 4.2 of the data sheet. Basically if you turn on code protection then the code cannot be read from the device by a programmer/debugger. If you try to reprogram the device to clear the code protection then the whole of the flash will be erased.
    Not sure what this has to do with the hex file though.
    Susan
    #17
    qhb
    Superb Member
    • Total Posts : 9998
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: switch case problem in mplabx ide v5.15 2019/03/20 19:06:17 (permalink)
    +1 (1)
    As Susan said, it prevents anyone reading out the code from your chip.
    It does NOT protect the hex file in any way. If someone gets a copy of that, they can burn the firmware into their own chips.
    If you need to secure the hex file, put it into a password protected ZIP file before sending it to anyone.
     

    Nearly there...
    #18
    prasanth R
    Starting Member
    • Total Posts : 60
    • Reward points : 0
    • Joined: 2017/01/10 04:46:37
    • Location: 0
    • Status: offline
    Re: switch case problem in mplabx ide v5.15 2019/03/20 21:46:27 (permalink)
    +1 (1)
    Dear qhb,
               We didn't send the hex file. We send the hex burned chip only if they can't read out the hex from chip that's fine.
        So using "Code Protect" is enough for us?
     
    Thanks & Regards,
    Prasanth.
    #19
    qhb
    Superb Member
    • Total Posts : 9998
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: switch case problem in mplabx ide v5.15 2019/03/20 21:56:24 (permalink)
    +2 (2)
    Correct. The binary image cannot be read out of the chip if the protect bits are set.
    Note, the Microchip datasheet warns you that this is not a 100% guarantee the chip cannot be read.
    Certainly no Microchip supplied programmer will do it, or any of the cheap clones.
    If someone is willing to spend unlimited amounts of money, there may be ways to extract the code, but it would almost certainly cost more than just writing it themselves from scratch.
     

    Nearly there...
    #20
    Page: 12 > Showing page 1 of 2
    Jump to:
    © 2019 APG vNext Commercial Version 4.5