Re: [Mspgcc-users] SR getting corrupted
On Thu, Sep 5, 2013 at 2:20 PM, ravim ravi.mandl...@gmail.com wrote: Thank you Gentlemen for the responses. I fear the same, my device does not wake up from LPM, and since everything depends on timer interrupt and it ceases to fire, the whole system does not other then interrupt of receiving packets. Here is my implementation of timer interrupt. Please correct me if I am doing it wrong. I call this initializeRandomTimer in main function void initializeRandomTimer(){ BCSCTL3 |= LFXT1S_2; TACCTL0 = CCIE; TACCR0= 437 ; TACTL = MC_1 | TASSEL_1 | ID_3; MC_1 is MC__UP, which counts up to CCR0 once then stops. ID_3 divides the input clock by 8. TASSEL_1 is TASSEL__ACLK which you configure to VLOCLK which is nominally 12 kHz. If you're dividing by 8, it's about 1500 Hz, which wraps at about 43 minutes. That you stop seeing activity after about 45-60 minutes (and that VLOCLK is often slower then 12 kHz) makes this look like a candidate source for the problem. I didn't see anything where you clear TAR (reset it to zero, e.g. with TACLR in the TACTL assignment), or where you reset the timer after the first time it fires. Look at whatever code is resetting your timer, and make sure it's done right. Or use MC_2 which does continuous, and reset the target threshold with either: TACCR0 += 437; or TACCR0 = TAR + 437; in your interrupt routine (think about the differences and pick the one appropriate to your needs). If in normal operation your timer does fire about every 300ms (437/1500) for the 45 minutes the system works then perhaps this isn't the issue. I'd still look pretty closely at the timer configuration. I don't know what this code you mention in your later mail does, but if it does what its use implies it would not cause the problem. (What it should do is save SR, disable interrupts, then restore SR. That'd be fine if interrupts are enabled at all other times.) bspIState_t intState; BSP_ENTER_CRITICAL_SECTION(intState); BSP_EXIT_CRITICAL_SECTION(intState); Peter } here is my ISR interrupt(TIMERA0_VECTOR) Timer_A (void) { if(++sendInterval = SENDINTERVAL){ radioReady=1; sendInterval = 0; } P1OUT ^= 0x01; if(++timercounter=20){ globaltimer++; timercounter=0; // radioReady=1; } __bic_SR_register_on_exit(LPM1_bits); } and here is my for loop in main for(;;){ //enter LPM1 __bis_SR_register(LPM1_bits); //TIMER interrupt fired //If our radio is ready to fire if(radioReady==1){ mrfiPacket_t packet; packet.frame[0] = 8+20; packet.frame[RXPACKET_HEADER] = TXHI; sendPacket(LOWPOWER, packet); } } my global interrupts are enabled in main. Timer gets stuck after an hour or so, when receiving a packet from similar other device. Thanks and Regards, Ravi On Thu, Sep 5, 2013 at 6:52 AM, Peter Bigot-4 [via MSP430 gcc - Users] ml-node+s1086195n6866...@n5.nabble.com wrote: Are you sure that there is an interrupt that will wake you from LPM1, that it is firing, and that when it finishes it clears the LPM flags on the stack so that the MCU will return to active mode? What you describe so far is exactly what should happen if no wakeup occurs. You should be able to examine the SR value from mspdebug or gdb since it's r2. On Thu, Sep 5, 2013 at 3:06 AM, Wayne Uroda [hidden email] http://user/SendEmail.jtp?type=nodenode=6866i=0 wrote: I don't think bt actually works correctly on mspgdb (at least it never has for me in the last 6 years). I recommend you check the sp directly with the info registers command (or simply i r). The sp is r1 if I recall correctly. Then you can dump the memory in your stack and do something of a manual backtrace - if you know the current pc (again available through the registers) and you have a full assembly listing it should be possible to spot the return addresses in the stack (or simply check every word, if it corresponds to a location in code just following where you called a function then it is likely a return address - note I've only ever done this in my own software which I know back-to-front and it is all 16bit addressing, no msp430x). Or, you could try mspdebug - I think it has many debugging features and probably has a working bt command (I am still use mspgdb though so I'm not sure). - Wayne On 05/09/2013, at 16:38, ravim [hidden email] http://user/SendEmail.jtp?type=nodenode=6866i=1 wrote: I am working on a project which involves CC2500 and msp430f2274. I have been struggling with a bug for more than 4 weeks, and still unable to debug it. My code stops working after an hour (just time, however device keep receiving packets) During my debugging, I have checked stack which is
Re: [Mspgcc-users] SR getting corrupted
Thanks Peter, I really appreciate your response. I tried so, however my error persists. I would be really grateful if you could answer one more question. I still get the timer stuck after 45-60 mins. I forgot to mention that I am doing a flash write too in my program , and in doing so , I disable and enable interrupts. This is the only place left where interrupts are being handled/changed /*Writes word (16 bits) to address location*/ void flash_write(uint16_t address, uint16_t word) { bspIState_t intState; BSP_ENTER_CRITICAL_SECTION(intState); //Disable interrupts FCTL2 = FWKEY + FSSEL1 + FN0; //Set SMCLK/2 FCTL3 = FWKEY; //Unlock memory FCTL1 = FWKEY + WRT; //Set to write FLSHRD(address) = word; //Write word to *ptr FCTL1 = FWKEY; //Clear write bit FCTL3 = FWKEY + LOCK; //Lock memory BSP_EXIT_CRITICAL_SECTION(intState); //Enable interrupts return; } Now, I am using BSP_ENTER_CRITICAL_SECTION(intState); to disable interrupts and preserve ISR state. My question, is do I still need to enable global interrupts here? Is this any way messing up SR registers? Thanks in advance, Ravi On Thu, Sep 5, 2013 at 3:57 PM, Peter Bigot-4 [via MSP430 gcc - Users] ml-node+s1086195n6868...@n5.nabble.com wrote: It's not necessarily wrong, but if there's a control path through sendPacket that leaves interrupts disabled what you observe would happen. Test that by either looking for GIE to be clear in SR when sendPacket returns, or work around it by using __bis_SR_register(LPM1_bits | GIE). There is a more esoteric possibility at https://sourceforge.net/p/mspgcc/bugs/341/ but I don't believe it affects the 2xx MCUs. Peter On Thu, Sep 5, 2013 at 2:20 PM, ravim [hidden email]http://user/SendEmail.jtp?type=nodenode=6868i=0 wrote: Thank you Gentlemen for the responses. I fear the same, my device does not wake up from LPM, and since everything depends on timer interrupt and it ceases to fire, the whole system does not other then interrupt of receiving packets. Here is my implementation of timer interrupt. Please correct me if I am doing it wrong. I call this initializeRandomTimer in main function void initializeRandomTimer(){ BCSCTL3 |= LFXT1S_2; TACCTL0 = CCIE; TACCR0= 437 ; TACTL = MC_1 | TASSEL_1 | ID_3; } here is my ISR interrupt(TIMERA0_VECTOR) Timer_A (void) { if(++sendInterval = SENDINTERVAL){ radioReady=1; sendInterval = 0; } P1OUT ^= 0x01; if(++timercounter=20){ globaltimer++; timercounter=0; // radioReady=1; } __bic_SR_register_on_exit(LPM1_bits); } and here is my for loop in main for(;;){ //enter LPM1 __bis_SR_register(LPM1_bits); //TIMER interrupt fired //If our radio is ready to fire if(radioReady==1){ mrfiPacket_t packet; packet.frame[0] = 8+20; packet.frame[RXPACKET_HEADER] = TXHI; sendPacket(LOWPOWER, packet); } } my global interrupts are enabled in main. Timer gets stuck after an hour or so, when receiving a packet from similar other device. Thanks and Regards, Ravi On Thu, Sep 5, 2013 at 6:52 AM, Peter Bigot-4 [via MSP430 gcc - Users] [hidden email] http://user/SendEmail.jtp?type=nodenode=6868i=1 wrote: Are you sure that there is an interrupt that will wake you from LPM1, that it is firing, and that when it finishes it clears the LPM flags on the stack so that the MCU will return to active mode? What you describe so far is exactly what should happen if no wakeup occurs. You should be able to examine the SR value from mspdebug or gdb since it's r2. On Thu, Sep 5, 2013 at 3:06 AM, Wayne Uroda [hidden email] http://user/SendEmail.jtp?type=nodenode=6866i=0 wrote: I don't think bt actually works correctly on mspgdb (at least it never has for me in the last 6 years). I recommend you check the sp directly with the info registers command (or simply i r). The sp is r1 if I recall correctly. Then you can dump the memory in your stack and do something of a manual backtrace - if you know the current pc (again available through the registers) and you have a full assembly listing it should be possible to spot the return addresses in the stack (or simply check every word, if it corresponds to a location in code just following where you called a function then it is likely a return address - note I've only ever done this in my own software which I know back-to-front and it is all 16bit addressing, no msp430x). Or, you could try mspdebug - I think it has many debugging features and probably has a working bt command (I am still use mspgdb though so I'm not sure). - Wayne On 05/09/2013, at 16:38, ravim [hidden email]
Re: [Mspgcc-users] SR getting corrupted
I don't think bt actually works correctly on mspgdb (at least it never has for me in the last 6 years). I recommend you check the sp directly with the info registers command (or simply i r). The sp is r1 if I recall correctly. Then you can dump the memory in your stack and do something of a manual backtrace - if you know the current pc (again available through the registers) and you have a full assembly listing it should be possible to spot the return addresses in the stack (or simply check every word, if it corresponds to a location in code just following where you called a function then it is likely a return address - note I've only ever done this in my own software which I know back-to-front and it is all 16bit addressing, no msp430x). Or, you could try mspdebug - I think it has many debugging features and probably has a working bt command (I am still use mspgdb though so I'm not sure). - Wayne On 05/09/2013, at 16:38, ravim ravi.mandl...@gmail.com wrote: I am working on a project which involves CC2500 and msp430f2274. I have been struggling with a bug for more than 4 weeks, and still unable to debug it. My code stops working after an hour (just time, however device keep receiving packets) During my debugging, I have checked stack which is fine. I checked globals too, which have legitimate values too. Whenever my code gets stuck, msp430-gdb bt always always gives me just this 0x8092 in main () When I dissemble my code around that address, 08084: b0 12 72 86 CALL#wor_start 08088: b0 12 38 90 CALL#initializeRandomTimer 0808c: 32 d2 EINT 0808e: 32 d0 50 00 BIS #0x0050, SR 08092: 5f 42 0e 02 MOV.B radioReady, R15 08096: 5f 93 CMP.B #0x0001, R15 I believe some how my SR is getting corrupted. I would really appreciate why it could be getting corrupted. I mean what could be possible reasons for getting SR corruption. Thanks and regards. Ravi -- View this message in context: http://msp430-gcc-users.1086195.n5.nabble.com/SR-getting-corrupted-tp6864.html Sent from the MSP430 gcc - Users mailing list archive at Nabble.com. -- Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more! Discover the easy way to master current and previous Microsoft technologies and advance your career. Get an incredible 1,500+ hours of step-by-step tutorial videos with LearnDevNow. Subscribe today and save! http://pubads.g.doubleclick.net/gampad/clk?id=58041391iu=/4140/ostg.clktrk ___ Mspgcc-users mailing list Mspgcc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mspgcc-users -- Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more! Discover the easy way to master current and previous Microsoft technologies and advance your career. Get an incredible 1,500+ hours of step-by-step tutorial videos with LearnDevNow. Subscribe today and save! http://pubads.g.doubleclick.net/gampad/clk?id=58041391iu=/4140/ostg.clktrk ___ Mspgcc-users mailing list Mspgcc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Re: [Mspgcc-users] SR getting corrupted
Are you sure that there is an interrupt that will wake you from LPM1, that it is firing, and that when it finishes it clears the LPM flags on the stack so that the MCU will return to active mode? What you describe so far is exactly what should happen if no wakeup occurs. You should be able to examine the SR value from mspdebug or gdb since it's r2. On Thu, Sep 5, 2013 at 3:06 AM, Wayne Uroda w.ur...@gmail.com wrote: I don't think bt actually works correctly on mspgdb (at least it never has for me in the last 6 years). I recommend you check the sp directly with the info registers command (or simply i r). The sp is r1 if I recall correctly. Then you can dump the memory in your stack and do something of a manual backtrace - if you know the current pc (again available through the registers) and you have a full assembly listing it should be possible to spot the return addresses in the stack (or simply check every word, if it corresponds to a location in code just following where you called a function then it is likely a return address - note I've only ever done this in my own software which I know back-to-front and it is all 16bit addressing, no msp430x). Or, you could try mspdebug - I think it has many debugging features and probably has a working bt command (I am still use mspgdb though so I'm not sure). - Wayne On 05/09/2013, at 16:38, ravim ravi.mandl...@gmail.com wrote: I am working on a project which involves CC2500 and msp430f2274. I have been struggling with a bug for more than 4 weeks, and still unable to debug it. My code stops working after an hour (just time, however device keep receiving packets) During my debugging, I have checked stack which is fine. I checked globals too, which have legitimate values too. Whenever my code gets stuck, msp430-gdb bt always always gives me just this 0x8092 in main () When I dissemble my code around that address, 08084: b0 12 72 86 CALL#wor_start 08088: b0 12 38 90 CALL#initializeRandomTimer 0808c: 32 d2 EINT 0808e: 32 d0 50 00 BIS #0x0050, SR 08092: 5f 42 0e 02 MOV.B radioReady, R15 08096: 5f 93 CMP.B #0x0001, R15 I believe some how my SR is getting corrupted. I would really appreciate why it could be getting corrupted. I mean what could be possible reasons for getting SR corruption. Thanks and regards. Ravi -- View this message in context: http://msp430-gcc-users.1086195.n5.nabble.com/SR-getting-corrupted-tp6864.html Sent from the MSP430 gcc - Users mailing list archive at Nabble.com. -- Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more! Discover the easy way to master current and previous Microsoft technologies and advance your career. Get an incredible 1,500+ hours of step-by-step tutorial videos with LearnDevNow. Subscribe today and save! http://pubads.g.doubleclick.net/gampad/clk?id=58041391iu=/4140/ostg.clktrk ___ Mspgcc-users mailing list Mspgcc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mspgcc-users -- Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more! Discover the easy way to master current and previous Microsoft technologies and advance your career. Get an incredible 1,500+ hours of step-by-step tutorial videos with LearnDevNow. Subscribe today and save! http://pubads.g.doubleclick.net/gampad/clk?id=58041391iu=/4140/ostg.clktrk ___ Mspgcc-users mailing list Mspgcc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mspgcc-users -- Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more! Discover the easy way to master current and previous Microsoft technologies and advance your career. Get an incredible 1,500+ hours of step-by-step tutorial videos with LearnDevNow. Subscribe today and save! http://pubads.g.doubleclick.net/gampad/clk?id=58041391iu=/4140/ostg.clktrk___ Mspgcc-users mailing list Mspgcc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Re: [Mspgcc-users] SR getting corrupted
It's not necessarily wrong, but if there's a control path through sendPacket that leaves interrupts disabled what you observe would happen. Test that by either looking for GIE to be clear in SR when sendPacket returns, or work around it by using __bis_SR_register(LPM1_bits | GIE). There is a more esoteric possibility at https://sourceforge.net/p/mspgcc/bugs/341/ but I don't believe it affects the 2xx MCUs. Peter On Thu, Sep 5, 2013 at 2:20 PM, ravim ravi.mandl...@gmail.com wrote: Thank you Gentlemen for the responses. I fear the same, my device does not wake up from LPM, and since everything depends on timer interrupt and it ceases to fire, the whole system does not other then interrupt of receiving packets. Here is my implementation of timer interrupt. Please correct me if I am doing it wrong. I call this initializeRandomTimer in main function void initializeRandomTimer(){ BCSCTL3 |= LFXT1S_2; TACCTL0 = CCIE; TACCR0= 437 ; TACTL = MC_1 | TASSEL_1 | ID_3; } here is my ISR interrupt(TIMERA0_VECTOR) Timer_A (void) { if(++sendInterval = SENDINTERVAL){ radioReady=1; sendInterval = 0; } P1OUT ^= 0x01; if(++timercounter=20){ globaltimer++; timercounter=0; // radioReady=1; } __bic_SR_register_on_exit(LPM1_bits); } and here is my for loop in main for(;;){ //enter LPM1 __bis_SR_register(LPM1_bits); //TIMER interrupt fired //If our radio is ready to fire if(radioReady==1){ mrfiPacket_t packet; packet.frame[0] = 8+20; packet.frame[RXPACKET_HEADER] = TXHI; sendPacket(LOWPOWER, packet); } } my global interrupts are enabled in main. Timer gets stuck after an hour or so, when receiving a packet from similar other device. Thanks and Regards, Ravi On Thu, Sep 5, 2013 at 6:52 AM, Peter Bigot-4 [via MSP430 gcc - Users] ml-node+s1086195n6866...@n5.nabble.com wrote: Are you sure that there is an interrupt that will wake you from LPM1, that it is firing, and that when it finishes it clears the LPM flags on the stack so that the MCU will return to active mode? What you describe so far is exactly what should happen if no wakeup occurs. You should be able to examine the SR value from mspdebug or gdb since it's r2. On Thu, Sep 5, 2013 at 3:06 AM, Wayne Uroda [hidden email] http://user/SendEmail.jtp?type=nodenode=6866i=0 wrote: I don't think bt actually works correctly on mspgdb (at least it never has for me in the last 6 years). I recommend you check the sp directly with the info registers command (or simply i r). The sp is r1 if I recall correctly. Then you can dump the memory in your stack and do something of a manual backtrace - if you know the current pc (again available through the registers) and you have a full assembly listing it should be possible to spot the return addresses in the stack (or simply check every word, if it corresponds to a location in code just following where you called a function then it is likely a return address - note I've only ever done this in my own software which I know back-to-front and it is all 16bit addressing, no msp430x). Or, you could try mspdebug - I think it has many debugging features and probably has a working bt command (I am still use mspgdb though so I'm not sure). - Wayne On 05/09/2013, at 16:38, ravim [hidden email] http://user/SendEmail.jtp?type=nodenode=6866i=1 wrote: I am working on a project which involves CC2500 and msp430f2274. I have been struggling with a bug for more than 4 weeks, and still unable to debug it. My code stops working after an hour (just time, however device keep receiving packets) During my debugging, I have checked stack which is fine. I checked globals too, which have legitimate values too. Whenever my code gets stuck, msp430-gdb bt always always gives me just this 0x8092 in main () When I dissemble my code around that address, 08084: b0 12 72 86 CALL#wor_start 08088: b0 12 38 90 CALL#initializeRandomTimer 0808c: 32 d2 EINT 0808e: 32 d0 50 00 BIS #0x0050, SR 08092: 5f 42 0e 02 MOV.B radioReady, R15 08096: 5f 93 CMP.B #0x0001, R15 I believe some how my SR is getting corrupted. I would really appreciate why it could be getting corrupted. I mean what could be possible reasons for getting SR corruption. Thanks and regards. Ravi -- View this message in context: http://msp430-gcc-users.1086195.n5.nabble.com/SR-getting-corrupted-tp6864.html Sent from the MSP430 gcc - Users mailing list archive at Nabble.com.
Re: [Mspgcc-users] SR getting corrupted
Thank you Gentlemen for the responses. I fear the same, my device does not wake up from LPM, and since everything depends on timer interrupt and it ceases to fire, the whole system does not other then interrupt of receiving packets. Here is my implementation of timer interrupt. Please correct me if I am doing it wrong. I call this initializeRandomTimer in main function void initializeRandomTimer(){ BCSCTL3 |= LFXT1S_2; TACCTL0 = CCIE; TACCR0= 437 ; TACTL = MC_1 | TASSEL_1 | ID_3; } here is my ISR interrupt(TIMERA0_VECTOR) Timer_A (void) { if(++sendInterval = SENDINTERVAL){ radioReady=1; sendInterval = 0; } P1OUT ^= 0x01; if(++timercounter=20){ globaltimer++; timercounter=0; // radioReady=1; } __bic_SR_register_on_exit(LPM1_bits); } and here is my for loop in main for(;;){ //enter LPM1 __bis_SR_register(LPM1_bits); //TIMER interrupt fired //If our radio is ready to fire if(radioReady==1){ mrfiPacket_t packet; packet.frame[0] = 8+20; packet.frame[RXPACKET_HEADER] = TXHI; sendPacket(LOWPOWER, packet); } } my global interrupts are enabled in main. Timer gets stuck after an hour or so, when receiving a packet from similar other device. Thanks and Regards, Ravi On Thu, Sep 5, 2013 at 6:52 AM, Peter Bigot-4 [via MSP430 gcc - Users] ml-node+s1086195n6866...@n5.nabble.com wrote: Are you sure that there is an interrupt that will wake you from LPM1, that it is firing, and that when it finishes it clears the LPM flags on the stack so that the MCU will return to active mode? What you describe so far is exactly what should happen if no wakeup occurs. You should be able to examine the SR value from mspdebug or gdb since it's r2. On Thu, Sep 5, 2013 at 3:06 AM, Wayne Uroda [hidden email]http://user/SendEmail.jtp?type=nodenode=6866i=0 wrote: I don't think bt actually works correctly on mspgdb (at least it never has for me in the last 6 years). I recommend you check the sp directly with the info registers command (or simply i r). The sp is r1 if I recall correctly. Then you can dump the memory in your stack and do something of a manual backtrace - if you know the current pc (again available through the registers) and you have a full assembly listing it should be possible to spot the return addresses in the stack (or simply check every word, if it corresponds to a location in code just following where you called a function then it is likely a return address - note I've only ever done this in my own software which I know back-to-front and it is all 16bit addressing, no msp430x). Or, you could try mspdebug - I think it has many debugging features and probably has a working bt command (I am still use mspgdb though so I'm not sure). - Wayne On 05/09/2013, at 16:38, ravim [hidden email]http://user/SendEmail.jtp?type=nodenode=6866i=1 wrote: I am working on a project which involves CC2500 and msp430f2274. I have been struggling with a bug for more than 4 weeks, and still unable to debug it. My code stops working after an hour (just time, however device keep receiving packets) During my debugging, I have checked stack which is fine. I checked globals too, which have legitimate values too. Whenever my code gets stuck, msp430-gdb bt always always gives me just this 0x8092 in main () When I dissemble my code around that address, 08084: b0 12 72 86 CALL#wor_start 08088: b0 12 38 90 CALL#initializeRandomTimer 0808c: 32 d2 EINT 0808e: 32 d0 50 00 BIS #0x0050, SR 08092: 5f 42 0e 02 MOV.B radioReady, R15 08096: 5f 93 CMP.B #0x0001, R15 I believe some how my SR is getting corrupted. I would really appreciate why it could be getting corrupted. I mean what could be possible reasons for getting SR corruption. Thanks and regards. Ravi -- View this message in context: http://msp430-gcc-users.1086195.n5.nabble.com/SR-getting-corrupted-tp6864.html Sent from the MSP430 gcc - Users mailing list archive at Nabble.com. -- Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more! Discover the easy way to master current and previous Microsoft technologies and advance your career. Get an incredible 1,500+ hours of step-by-step tutorial videos with LearnDevNow. Subscribe today and save! http://pubads.g.doubleclick.net/gampad/clk?id=58041391iu=/4140/ostg.clktrk ___ Mspgcc-users mailing list [hidden email] http://user/SendEmail.jtp?type=nodenode=6866i=2