I have a small but annoying issue when using the USB JTAG Tiny with an Olimex P149 Proto board.
I have an application where the bulk of the code resides in Flash @ 0x7000, but has an algorithm currently located in RAM @ 0x200 because it’s continually evolving and I’m simply saving Flash wear cycles.
The issue is whenever code is changed resulting in different code length the first JTAG download fails to verify because the memory word at 0x200 is overwritten with the value 0x200 instead of the mov #0A00h,sp instruction.
Cancelling the Kickstart debug session and restarting it always succeeds.
The first debug download of the day always succeeds.
If the code is unchanged in length the download always succeeds even if the code is different.
OLIMEX:
Correctme if I’m wrong but the Option Retain memory will not do Erase? so why do you wonder that Verify fails when code is changing?
No, that option only erases IF the code has changed. It will still change & rewrite memory if necessary. It's only intended to save unnecessary FLASH erase/write cycles. Strictly it's called "Retain unchanged memory".
In any case the error is that a value, coincidentally 0x200 is erroneously written to address 0x200. That value never changes in the code, it is ALWAYS a stack initialisation instruction.
OK - I have now distilled a very simple project that demonstrates the problem. The fact most of the code was in FLASH and some is in RAM doesn’t seem relevant.
I’ve isolated the problem to when one of the interrupt vectors points to code in RAM that has moved since the last JTAG download. Very strange indeed and possibly points to an issue with Kickstart.
If the ‘nop’ at label ‘stackclr’ is alternately commented out then not between each compilation/download then I get the download verification error every time. Again address 0x200 is overwritten with value 0x200. The next download without changing any code always succeeds.
I can zip up the whole project and send it to you - to what address should I send it?
#include "msp430x14x.h"
;******************************************************************************
RSEG CSTACK ; FORWARD declaration of stack segment
RSEG RAM ; Program Start
;------------------------------------------------------------------------------
main
start mov.w #sfe(CSTACK),SP ; Initialize stackpointer
StopWDT mov.w #WDTPW+WDTHOLD, &WDTCTL ; Stop WDT
mov #sfb(CSTACK), r12
stackclr nop
jmp $
TAX_ISR add &TAIV, PC ; Add Timer_A offset vector
reti ; CCR0 - no source
jmp CCR1_ISR ; CCR1
jmp CCR2_ISR ; CCR2
reti ; CCR3
reti ; CCR4
TA_over xor.b #001h,&P1OUT ; Toggle P1.0
reti ; Return from overflow ISR
CCR1_ISR XOR #OUTMOD2, &TACCTL1 ;toggle set/reset next o/p
BIT #OUTMOD2, &TACCTL1
; SNIP
;TACCR2 irq handler
CCR2_ISR MOV &TACCR2, r4 ;read capture value from serial pulse stream
; SNIP
;------------------------------------------------------------------------------
; Interrupt Vectors Used - MSP430F149
;------------------------------------------------------------------------------
RSEG INTVEC:CONST
ORG TIMERA1_VECTOR
DW TAX_ISR
ORG NMI_VECTOR ;
DW start ; MSP430 NMI Vector
DW start ; MSP430 RST Vector
END
please e-mail (info at olimex dot com) your complete project (including your EW project files) only from this assembly code we can’t reproduce your result
//*****************************************************************
// XLINK command file for the MSP430 IAR C/C++ Compiler
//
// This is the XLINK command file for the MSP430F149
// microprocessor.
//
// Copyright 1996-2004 IAR Systems. All rights reserved.
//
// Usage: xlink your_file(s) -f lnkMSP430F149 cl430xxx
//
// $Revision: 1.0 $
//
//*****************************************************************
//*****************************************************************
// The following segments are defined in this linker command file:
//
// Data read/write segments (RAM)
// ==============================
//
// segment address range usage
// ------- ------------- --------------------------
// DATA16_I 0200-09FF Initialized variables
// DATA16_Z 0200-09FF Zero initialized variables
// DATA16_N 0200-09FF Uninitialized variables
// CSTACK 0200-09FF Run-time stack/auto variables
// HEAP 0200-09FF The heap used by malloc and free
//
//
// Program and non-volatile segments (FLASH)
// =========================================
//
// segment address range usage
// ------- ------------- --------------------------
// INFO 1000-10FF Information memory
// CSTART 1100-FFDF cstartup program code
// CODE 1100-FFDF Program code
// DATA16_C 1100-FFDF Constant "const" variables AND String literals
// DATA16_ID 1100-FFDF Initializers for DATA16_I
// DIFUNCT 1100-FFDF Dynamic initialization vector used by C++
// CHECKSUM 1100-FFDF The linker places the checksum byte(s) in this segment,
// when the -J linker command line option is used.
//
// INTVEC FFE0-FFFF Interrupt vectors
//
// NOTE:
// It is not possible to pack the CSTART segment by using the XLINK -P option
// Special function registers and peripheral modules occupy addresses 0-01FFh
// Be sure to use end values for the defined addresses
//*****************************************************************
// -------------------------------------------------------------------
// Stack size and heap size
// -------------------------------------------------------------------
// Uncomment for command line use
//-D_STACK_SIZE=50
//-D_HEAP_SIZE=50
// -------------------------------------------------------------------
// Define CPU
// -------------------------------------------------------------------
-cmsp430
// -------------------------------------------------------------------
// RAM memory
// -------------------------------------------------------------------
-Z(CODE)RAM=0200-09FF
-Z(DATA)DATA16_I,DATA16_Z,DATA16_N,DATA,HEAP+_HEAP_SIZE=0200-09FF
-Z(DATA)CSTACK+_STACK_SIZE#
// -------------------------------------------------------------------
// Information memory (FLASH)
// -------------------------------------------------------------------
-Z(CODE)INFO=1000-10FF
-Z(CODE)INFOA=1080-10FF
-Z(CODE)INFOB=1000-107F
// -------------------------------------------------------------------
// ROM memory (FLASH)
// -------------------------------------------------------------------
// Code
-Z(CODE)BOOT=1000-11FF
-Z(CODE)LANG=3E00-6FFF
-Z(CODE)CSTART=7000-FFDF
-Z(CODE)CODE=7000-FFDF
// Constant data
-Z(CONST)DATA16_C,DATA16_ID,DIFUNCT,CHECKSUM=7000-FFDF
// Interrupt vectors
-Z(CONST)INTVEC=FFE0-FFFF
-Z(CONST)RESET=FFFE-FFFF
// -------------------------------------------------------------------
// End of File
// -------------------------------------------------------------------
OldCow:
I tried your code, but I got a XLINK error. RSEG RAM is not defined. I added a -Z command to the xlc file and use TI parallel port FET tool to test your code. The result is the same as yours.
Link file posted above. You mean you get a verify error on download? If so then it's pretty strange, but at least it's consistent and presumably points to a Kickstart error rather than the USB Tiny JTAG.
I’ll still mail the project to Tsvetan in case he has some ideas. Thanks for the help so far guys.
I’ve had a reply from Tsvetan at Olimex about this issue and he’s confirmed that he gets the same faulty result with a range of JTAG adaptors for my example project.
So the fault lies elsewhere and not with JTAG Tiny. I just wanted to make it clear.