simpleavr 399 Posted December 3, 2010 Share Posted December 3, 2010 i haven't got a chance to port the assembler and try it yet. but if u have a "c" and a "asm" source, i would rename the .asm to .s and use $GCCBIN/msp430-gcc -D_GNU_ASSEMBLER_ -x assembler-with-cpp -c dco_lib.s -o dco_lib.o $GCCBIN/msp430-gcc -Os -mmcu=msp430x2013 -c setdco.c -o setdco.o $GCCBIN/msp430-gcc -mmcu=msp430x2013 -o setdco.elf dco_lib.o setdco.o or something similar this may or may not work, depending on how the assembly was coded (it's machine level now), may require tweaks. but you can do $GCCBIN/msp430-objdump -DS setdco.elf > setdco.lst and get a list file and examine it, see if the linker does a good job bridging the assembly and the c (w/o stepping into each other, i.e. use of registers) i am not an assembler guy but do use in-lines and functions from time to time. [EDIT] if your compile failed, it's because u need to definitely "port" the assembly code, IAR/CCS is using quite a bit of directives that gnu assembler does not recognize, if in doubt, google for a gnu assembler menu (i think msp430-gcc is just gnu + some extensions), this will help the porting. jbremnant 1 Quote Link to post Share on other sites
simpleavr 399 Posted December 3, 2010 Share Posted December 3, 2010 mspdebug rf2500 "dis 0x10F8 8" ... Device: MSP430G2231 Code memory starts at 0xf800 Number of breakpoints: 1 010f8: 91 8f 99 8e 88 8d SUB 0x8e99(R15), 0x8d88(SP) 010fe: 40 87 SUB.B R7, PC btw, your calibrated values looks better (closer to spec) than mine. the reason that i want to validate / verify more is that if i tried to calibrated it many times in a row, i am not getting consistent results. they are close though. w/ u showing your results, now i tend to think that i need to solder the crystal in place and try again. i was before just "attaching" the crystal. Quote Link to post Share on other sites
jbremnant 17 Posted December 4, 2010 Share Posted December 4, 2010 Yes, it renamed the file to .s and tried the similar compile flags you listed above. In fact, your msp430-gcc commands look a lot like cmds in my Makefile. [EDIT][/b] if your compile failed, it's because u need to definitely "port" the assembly code, IAR/CCS is using quite a bit of directives that gnu assembler does not recognize, if in doubt, google for a gnu assembler menu (i think msp430-gcc is just gnu + some extensions), this will help the porting. As you have guessed, it seems like the asm code was specific to IAR/CCS since it complained about nonexistent pseudo-ops and opcodes... like below: dco_lib.s: Assembler messages: dco_lib.s:75: Error: unknown pseudo-op: `.cdecls' dco_lib.s:78: Error: unknown pseudo-op: `.def' dco_lib.s:85: Error: unknown opcode `device_type' dco_lib.s:87: Error: non-constant expression in ".if" statement dco_lib.s:87: Error: junk at end of line, first unrecognized character is `=' Quote Link to post Share on other sites
jbremnant 17 Posted December 4, 2010 Share Posted December 4, 2010 btw, your calibrated values looks better (closer to spec) than mine. the reason that i want to validate / verify more is that if i tried to calibrated it many times in a row, i am not getting consistent results. they are close though. w/ u showing your results, now i tend to think that i need to solder the crystal in place and try again. i was before just "attaching" the crystal. Hmm.. I used a different 32k crystal from the one packaged in with the launchpad. (maybe the one I am using has tighter tolerances?) The leads are longer so I put it directly on the breadboard and tested it out on msp430g2211. Let me do some regression testing and see how the number varies on each run. I'd like to know the mean and the standard deviation of the values from at least 20 runs. Quote Link to post Share on other sites
GeekDoc 226 Posted December 4, 2010 Share Posted December 4, 2010 I'd like to know the mean and the standard deviation of the values from at least 20 runs. Sounds like someone paid attention in Statistics class! Glad we have smart people testing this out! Quote Link to post Share on other sites
simpleavr 399 Posted December 4, 2010 Share Posted December 4, 2010 As you have guessed, it seems like the asm code was specific to IAR/CCS since it complained about nonexistent pseudo-ops and opcodes... i got the .s compiled through the initial portion of the assembly code changed to like this ;Functions ;.def TI_SetDCO .global TI_SetDCO .align 2 .text .set DEVICE_TYPE, 3 ; 2xx devices with a Timer_A2 .if DEVICE_TYPE == 3 ; For Timer_A2 devices .set TACCTLX, TACCTL0 .set TACCRX, TACCR0 .else .set TACCTLX, TACCTL2 .set TACCRX, TACCR2 .endif ;------------------------------------------------------------------------------- TI_SetDCO:; Subroutine: Sets DCO to selected frequency based on Delta. [EDIT] the ";TI_SetDCO:;...." label should be uncommented, ie. "TI_SetDCO:;..." for the rest of the code use note the following rules . the ".set" syntax is different, need to swap position . all the labels must have trailing colons . the ".if" directive is also a bit different, need c style == compare * also not sure about the complier -mmcu flag, may need to try -mmcu=msp430x2012 instead of -mmcu=msp430x2013, the g2231 should actually be closer to f2012 according to specification. i am not going to try flash it today, there may be other issues. but this should let u create the firmware in linux you can look into the the output .lst file to gain detail if things does not work out well. Quote Link to post Share on other sites
simpleavr 399 Posted December 4, 2010 Share Posted December 4, 2010 I'd like to know the mean and the standard deviation of the values from at least 20 runs. Sounds like someone paid attention in Statistics class! Glad we have smart people testing this out! only if i have a scope may be i will built a frequency counter Quote Link to post Share on other sites
simpleavr 399 Posted December 4, 2010 Share Posted December 4, 2010 Hmm.. I used a different 32k crystal from the one packaged in with the launchpad. (maybe the one I am using has tighter tolerances?) The leads are longer so I put it directly on the breadboard and tested it out on msp430g2211. same here, i am using a crystal from a mcdonald toy watch that came from a happy meal. and doc told us that we are smart. Quote Link to post Share on other sites
jbremnant 17 Posted December 4, 2010 Share Posted December 4, 2010 Ooh... thanks for that snippet of asm code. I gotta try this out now. I'd like to know the mean and the standard deviation of the values from at least 20 runs. Sounds like someone paid attention in Statistics class! Glad we have smart people testing this out! only if i have a scope may be i will built a frequency counter @GeekDoc I studied stats in grad school and almost shot myself. Somehow I got through it.. @simpleavr maybe I should buy an oscilloscope... hmm... Quote Link to post Share on other sites
GeekDoc 226 Posted December 4, 2010 Share Posted December 4, 2010 NJC was working on a 'scope for the LaunchPad (LP + PC), but he seems to have disappeared. He hasn't posted since October; here or on his blog. Quote Link to post Share on other sites
simpleavr 399 Posted December 5, 2010 Share Posted December 5, 2010 it was the crystal all along. the c example msp430x20xx_dco_flashcal.c (from slau80) has been working all right. i finally solder a 32khz crystal onto my launchpad, result became better but still give inconsistent result, result looks ok, but if i run the calibration continuously for a few times, they are always off a bit. i then remove and solder the ti supplied crystal and i can get very good results. . i don't need to tweak the code for tolerance on expected values as before. . i get consistent results if i run it many times in a row. . and the time to get it calibrated is like what NatureTM found from the assembler code, < 5 secs. so it's reliable to use this. for CCS/IAR users, u may need to add the missing range pointers via an include file, like what NatureTM suggested. mspgcc users already have them as we are just treating the G2231 as a F2012. if u had more than one launchpad, u can make one of them as a calibration stations, and solder in the ti supplied crystal and use it to calibrated all your chips. you should do it in the normal environment (temperature) that your project will run, as crystals are affected by temperatures. i had, though, no idea why my hello-kitty watch crystal did not work w/ the device. they work well on the toy. :? . could be the capacitor matching is not for the average clock crystal. anyway i am not going to try and find out. bluehash and GeekDoc 2 Quote Link to post Share on other sites
NatureTM 100 Posted December 5, 2010 Author Share Posted December 5, 2010 Nice job, simpleavr. So annoying when you spend tons of time trying to find a bug, only to realize it was a hardware issue. Quote Link to post Share on other sites
GeekDoc 226 Posted December 5, 2010 Share Posted December 5, 2010 if u had more than one launchpad, u can make one of them as a calibration stations, and solder in the ti supplied crystal and use it to calibrated all your chips. Exactly what I plan to do. Thanks for all the research. Quote Link to post Share on other sites
gordon 229 Posted May 27, 2011 Share Posted May 27, 2011 Just bumped into tinyos-msp430 (which is apparently not the same as the MSP430 support in mainline TinyOS). Relevance to this thread, notice "calibrate-dco" in the "featured downloads" section -- appears to be a quite beefed-up DCO calibration app, with goodies on the side (taking silicon errata into account for various devices when calibrating). NatureTM and bluehash 2 Quote Link to post Share on other sites
jsolarski 94 Posted May 30, 2011 Share Posted May 30, 2011 You can also use the DCO calibration code to customize your calibration, recently I have changed a bunch of my F2013s to Default on 2MHz on startup. Basically I overwrote the 1MHz calibration with 2 MHz data, tested on my scope and it works like a charm, also loaded up another blink led program and they work with the 2MHz settings . http://justinstech.org/2011/05/msp430-c ... n-for-dco/ What this means is you could set all 3 settings to whatever you need them to be. Tested DCO calibration down to 500K, im looking to go lower later, and works up to 16MHz, have not tested any higher. NatureTM 1 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.