tripwire 139 Posted February 1, 2015 Share Posted February 1, 2015 [...] if (P1IN & BTN==0) //check button status I'm afraid you've fallen into one of the traps set by the designers of C there. They got the precedence of the bitwise operators wrong, so that line will be evaluated as: if (P1IN & (BTN==0)) Instead of what you'd expect it to do: if ((P1IN & BTN)==0) You need to include the parentheses around P1IN & BTN to get the correct result. That doesn't explain why CCS can't find the out file, though. Take a look in the C:\Users\Jake\Google Drive\CCS\Turn lights on\Debug\ folder to see if it's there or not. If it is there maybe CCS is having trouble with spaces in the file path. If there's no out file that suggests CCS hit some errors during the build and failed to write it. Try right clicking on your project in the "Project Explorer" view and select "Clean Project". Then build it again and see if there are any errors in the "Console" view. If you can't see what's wrong copy all the console output into a text file and attach it here. Jake 1 Quote Link to post Share on other sites
abecedarian 330 Posted February 1, 2015 Share Posted February 1, 2015 Another thing- you have one too many left curly braces following the "for" statement. Jake 1 Quote Link to post Share on other sites
Jake 24 Posted February 1, 2015 Author Share Posted February 1, 2015 I'm afraid you've fallen into one of the traps set by the designers of C there. They got the precedence of the bitwise operators wrong, so that line will be evaluated as: if (P1IN & (BTN==0)) Instead of what you'd expect it to do: if ((P1IN & BTN)==0) You need to include the parentheses around P1IN & BTN to get the correct result. That doesn't explain why CCS can't find the out file, though. Take a look in the C:\Users\Jake\Google Drive\CCS\Turn lights on\Debug\ folder to see if it's there or not. If it is there maybe CCS is having trouble with spaces in the file path. If there's no out file that suggests CCS hit some errors during the build and failed to write it. Try right clicking on your project in the "Project Explorer" view and select "Clean Project". Then build it again and see if there are any errors in the "Console" view. If you can't see what's wrong copy all the console output into a text file and attach it here.'' You were right on the no .out file, it was pissy about something else and did not write it. I found that right after the server here took a nap again. I had to hit the pin console button to get the console to not clear out, that is when I saw it said it did not get written. I will try the extra set of parenthesis and fix the bracket issue, ( I thought I had them!!) Who knew turning on a LED could whip me this bad..... Thanks again for all the help! Quote Link to post Share on other sites
zeke 693 Posted February 3, 2015 Share Posted February 3, 2015 @Jake: Bravo! Keep growing! It gets easier as you climb this learning curve. You will never forget these lessons. We all had to learn them as well. Soon, you will start to feel like you are in control. At that time, you will say to yourself that there is nothing that you cannot program! Quote Link to post Share on other sites
Jake 24 Posted February 6, 2015 Author Share Posted February 6, 2015 Well I think I have gotten a bit closer, I am down to these errors. >> Compilation failureerror #10234-D: unresolved symbols remainerror #10010: errors encountered during linking; "lightings.out" not builtgmake: *** [lightings.out] Error 1gmake: Target `all' not remade because of errors. Do yall have any ideas on what may be leading to that? thanks!! #include <msp430g2553.h> #define red_LED BIT0 #define grn_LED BIT6 #define BTN BIT3 void delay(void); void main(void) { WDTCTL = WDTPW + WDTHOLD; // disable watchdog P1OUT &= ~grn_LED; P1OUT &= ~red_LED; P1OUT |= BTN; P1REN |= BTN; P1DIR &= ~BTN; P1DIR |= grn_LED; P1DIR |= red_LED; for(; if ((P1IN & BTN) == 8) //check button status { P1OUT |= grn_LED; //if button status meets make P1OUT HIGH delay(); } else { P1OUT &=grn_LED; P1OUT |=red_LED; delay(); } return 0; } Quote Link to post Share on other sites
tripwire 139 Posted February 6, 2015 Share Posted February 6, 2015 error #10234-D: unresolved symbols remain This means that the linker has failed because you're calling a function that isn't defined anywhere (ie you've given a prototype but the linker can't find the corresponding function body). The console window should show a list of the names of these undefined symbols somewhere. Quote Link to post Share on other sites
Jake 24 Posted February 10, 2015 Author Share Posted February 10, 2015 Well I have gotten closer I think.... With the help of my Analog Discovery, I have been able to get the button to work to make a logic change on P1.3....But I still can not get it to make an output from there. Here is the code, what can I do to make the led work and what do yall see that can make this better? Thanks again for all the help!! #include <msp430g2553.h> #define LEDG BIT0 // P1.0 #define BTN BIT3 // P1.3 void delay(void); void main(void) { WDTCTL = WDTPW + WDTHOLD; P1DIR &= ~BTN; P1OUT |= BTN; P1REN |= BTN; P1SEL |= BTN; P1OUT |= LEDG; for(; { if ((P1IN & BTN) == 0) { P1OUT |= LEDG; delay(); } else { P1OUT &= ~LEDG; delay(); } } } // delay void delay (void) { int i; for (i=0; i<0xff; i++){ } } Quote Link to post Share on other sites
tripwire 139 Posted February 10, 2015 Share Posted February 10, 2015 P1SEL |= BTN; You shouldn't need to set P1SEL for the button (or the LED), setting bits in PxSEL chooses the peripheral function for the corresponding pin (ie not GPIO function). Also, a small suggestion on programming style: it's better to use the __delay_cycles() intrinsic than roll-your-own delay loops. __delay_cycles() takes one parameter telling it how many MCLK cycles to wait for, and then the compiler generates code to use exactly that many cycles. It gives predicatable timing, and there's no risk of the compiler optimising it out. Quote Link to post Share on other sites
Jake 24 Posted February 10, 2015 Author Share Posted February 10, 2015 Thanks tripwire, I'll try that tonight. Quote Link to post Share on other sites
Jake 24 Posted February 11, 2015 Author Share Posted February 11, 2015 OK I took out the PSEL and I still am able to show a change on the input on the switch P1.3, But I still can not get an output, I tried the _delay_cycles() and it appears that I have more setup to do for that to work correctly. Just changing the code to _delay_cycles() the compiler was not happy about that. Thanks again for the help!!!! Quote Link to post Share on other sites
tripwire 139 Posted February 11, 2015 Share Posted February 11, 2015 OK I took out the PSEL and I still am able to show a change on the input on the switch P1.3, But I still can not get an output, I tried the _delay_cycles() and it appears that I have more setup to do for that to work correctly. Just changing the code to _delay_cycles() the compiler was not happy about that. Thanks again for the help!!!! You need to pass __delay_cycles a number of cycles to wait for, eg "__delay_cycles(40)" will busy wait for 40 cycles. That would give a 40 microsecond delay if MCLK frequency is set to 1MHz. MSP430G2553 will default to approx 1.1MHz on startup, which is good enough for rough timing. If you need more accuracy you can use the DCO calibration constants to set it to 1MHz. Jake 1 Quote Link to post Share on other sites
Jake 24 Posted February 11, 2015 Author Share Posted February 11, 2015 IT WOOORRRRRRKKKKKKKSSSSSS!!!! Who would have thought turning on a light would give me such joy to finally get to it! I got the delay function working well from your help also! The 3rd Lab in the launchpad Lab had pieces of the delay in it. Thanks again to everybody for there help. Now onto the next project! #include <msp430g2553.h> #define LEDG BIT0 // P1.0 #define BTN BIT3 // P1.3 #ifndef TIMER0_A1_VECTOR #define TIMER0_A1_VECTOR TIMERA1_VECTOR #define TIMER0_A0_VECTOR TIMERA0_VECTOR #endif void FaultRoutine(void); void main(void) { WDTCTL = WDTPW + WDTHOLD; P1DIR &= ~BTN; P1OUT |= BTN; P1REN |= BTN; P1OUT &= ~LEDG; P1DIR = LEDG; if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF) FaultRoutine(); // If calibration data is erased // run FaultRoutine() BCSCTL1 = CALBC1_1MHZ; // Set range DCOCTL = CALDCO_1MHZ; // Set DCO step + modulation BCSCTL3 |= LFXT1S_0; // LFXT1 = 32768 crystal IFG1 &= ~OFIFG; // Clear OSCFault flag BCSCTL2 |= SELM_0 + DIVM_3; // MCLK = DCO/8 for (; { if ((P1IN & BTN) == 0) { P1OUT |= LEDG; _delay_cycles(100000); } else{ P1OUT &= ~LEDG; _delay_cycles(100000); } } } void FaultRoutine(void) { int i; for (i=0; i<0xff; i++){ } } 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.