This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2530 banked code problem - IAR changes I/O port

Other Parts Discussed in Thread: CC2530, CC2540

I've submitted a support request to IAR asking about this, but I though I would describe my problem, maybe someone will have an idea, or it might be a useful heads-up if someone else encounters the problem.

My CC2530 project was getting close to the 32K limit so I switched to a banked code mode, using the banked linker file.

I had a debug LED on port 1 bit 4 and noticed that it was coming on when I made ANY call to banked code.

In the debugger, I stepped through the disassembly view and I was astonished to find that one of the function used to relay calls from root code to banked functions, named ?BDISPATCH_30 was messing with port 1!

I could probably work around this if I could force library functions like memcpy to link into the root bank, and only put code in the switched bank that I can tolerate having port 1 messed up, but I can't figure out how to do that.

?BDISPATCH_30 goes something like this:

MOV A,P1

SWAP A

ANL A, #30

.....

MOV P1, A

RET

At this point my debug LED turns on, it was off going into this function.

  • Your code bank options have probably been set up incorrectly. For a 256 KB device, they should be set up as follows (reduce the number of banks for smaller devices):

    Note that for IAR v. 7.60 and 8.10, I believe this should be correctly set up by default if you select the right chip as target device:

    edit: Tried once more to get the screenshots to display properly

  • Thanks, that was it.

    My device was generic CC2530, changing it to the specific CC2530F128 that I am using.

    Now the codebank tab is correct (3 banks) and stepping through a banked code call, it's now using a ?BDISPATCH_FF function that does not mess with P1.

    (BTW I tried to click the Verify button but nothing seemed to happen?)

  • I am glad this solved your issue. It seems the verify button worked after all, as my answer is now marked as verified. Thanks for doing that, it makes the forums easier to manage.

  • I'm having a very similar problem with my CC2540 256kb project. After waking up from sleep, my debug led is blinking and I believe it is also related to the BDISPATCH function. However, my code bank setup is already correct as according to your post. Anything else that can cause this issue?

    If I single step through the code it either doesn't happen or IAR hangs up so I don't know exactly where it is.

  • Hi.,

    I'm having a very similar problem with my CC2540 256kb project.

     

    Error[e104]: Failed to fit all segments into specified ranges. Problem discovered in segment BANKED_CODE. Unable to place 71 block(s) (0x1b47c byte(s) total) in 0x1af20 
    byte(s) of memory. The problem occurred while processing the segment placement command 
    "-P(CODE)BANKED_CODE=_CODE_BEG-_CODE_END,_BANK4_BEG-_BANK4_END,_BANK5_BEG-_BANK5_END,_BANK6_BEG-_BANK6_END,_BANK7_BEG-_BANK7_ 
    END", where at the moment of placement the available memory ranges were "CODE:3db4-3ff7,CODE:4b000-4ffff,CODE:58b24-5ffff,CODE:68000-6ffff,CODE:78000-7e7ff" 
    Error while running Linker

    Here if i am changing code memory or disable power saving(xPOWER_SAVING). its working without error but its not advertising.

    I am using BLE1.4 stack(Which i am converting 1.3.2 to 1.4). IAR Worbench 8.20.2.

    Suggestions welcome,

    Best wishes with thanks,

    MANO MM

  • This is the wrong forum, try the Bluetooth® Low Energy Forum. If you search there, you will for instance find this thread: http://e2e.ti.com/support/wireless_connectivity/f/538/t/303921.aspx