crobertsbmw 0 Posted November 20, 2011 Share Posted November 20, 2011 I feel like an idiot asking this question. I had this program working on my msp430f2274. Now I am trying to play with it using CCSv5 and putting it on the launchpad. For some reason it is skipping over my subroutines. #include #include //*********************************************************************** void delaySec(int n){ int i; int j; int k; for (i=0;i for (k=0;k<1000;k++){ for (j=0;j<100;j++){ ;} } } } void main(void) { WDTCTL = WDTPW + WDTHOLD; //disable watchdog delaySec(2); P1DIR = 0xFE; //set p1.6 as output,and P1.0 as input. P1OUT = 0x40; //p1.6 is pulled down while (1){ delaySec(10); P1OUT = 0x00; //p1.6 is pulled up delaySec(10); P1OUT = 0x40; //p1.6 is pulled down } } Please don't make fun of my delay loops. Quote Link to post Share on other sites
bluehash 1,581 Posted November 20, 2011 Share Posted November 20, 2011 - Post a full test program. - Are any optimizations turned on. Quote Link to post Share on other sites
crobertsbmw 0 Posted November 20, 2011 Author Share Posted November 20, 2011 - Post a full test program.- Are any optimizations turned on. I just edited and added the #includes, with that it is my full test program. I just installed CCSv5 on this computer today so all the defaults are intact. I went into project properties and looked at optimizations and it was at level 0. So I don't think so. Is that what you are talking about? Quote Link to post Share on other sites
bluehash 1,581 Posted November 20, 2011 Share Posted November 20, 2011 Try a clean and rebuild. Also, do something in the loop, like an x=x+1 or nop; I think you compiler is being clever and optimizing it out. crobertsbmw 1 Quote Link to post Share on other sites
oPossum 1,083 Posted November 20, 2011 Share Posted November 20, 2011 void delaySec(unsigned n) { do __delay_cycles(1000000); while(--n); } Your code does not work because i, j, & k are not declared volatile, so the compiler removes the empty for() loops. bluehash and crobertsbmw 2 Quote Link to post Share on other sites
crobertsbmw 0 Posted November 20, 2011 Author Share Posted November 20, 2011 Blue Hash, you were right. oPossum, thanks for that delay loop. Very clean. 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.