tech_juggernaut 5 Posted April 24, 2012 Share Posted April 24, 2012 Thanks! So in the final code, TIMER0_A0_VECTOR is called when the count matches CCR0, and then ADC10_VECTOR is called when the count resets to 0? I guess I was thinking it generated an Interrupt based on the change in the levels of the analog signals?... Quote Link to post Share on other sites
oPossum 1,083 Posted April 24, 2012 Share Posted April 24, 2012 ADC10_VECTOR is called when the ADC is done with conversion, or if DTC (data transfer controller) is being used then it is called at the end of the DTC cycle. The start of ADC conversion has to be triggered by code - it doesn't sense a change in voltage. tech_juggernaut 1 Quote Link to post Share on other sites
RobG 1,892 Posted April 24, 2012 Author Share Posted April 24, 2012 When CCR reaches your count value, TIMER0_A0_VECTOR is called. Servos are then updated and ADC sampling/conversion is started (all inside timer's ISR.) After ADC is done, ADC10_VECTOR is called and new servo positions are calculated. tech_juggernaut 1 Quote Link to post Share on other sites
zeke 693 Posted April 24, 2012 Share Posted April 24, 2012 Just to clarify, does the const declaration remove the array from RAM and stuff it into FLASH? Quote Link to post Share on other sites
oPossum 1,083 Posted April 24, 2012 Share Posted April 24, 2012 Yes, using const will usually put stuff in flash rather than RAM. This is not part of the C/C++ spec, but rather an obvious and common optimization done by compilers for embedded systems. Some compilers may require a special #pragma or other directive to ensure placement in flash - CCS and MSPGCC do not. Linker files can also be used to effect proper placement, but that is usually only done in special cases. tech_juggernaut and zeke 2 Quote Link to post Share on other sites
tech_juggernaut 5 Posted May 1, 2012 Share Posted May 1, 2012 Do you know how I could translate the CCR values to an actual position in degrees? I thought it would be cool to be able to output its actual position to a PC via serial. Is something like that possible? Thanks! Quote Link to post Share on other sites
oPossum 1,083 Posted May 1, 2012 Share Posted May 1, 2012 int deg = ((CCR - 187) * 184) >> 8; tech_juggernaut 1 Quote Link to post Share on other sites
spoil9 1 Posted January 11, 2013 Share Posted January 11, 2013 Rob, Thank you for posting all this sample code. Not being a C programmer, I'm still a little confused by it but I'm learning. I have a question though, when watching all the videos I noticed that the servos only rotated 90 degrees, which mine did as well. Is this just the way the way the 430 handles servos or is there something I can change in the code to allow a full 180 degree rotation? Thanks. Quote Link to post Share on other sites
RobG 1,892 Posted January 11, 2013 Author Share Posted January 11, 2013 You can change it in the code by adjusting min and max CCR value. 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.