EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

ez430-RF2500 simpliciTI and GPIO problem

Started by Kostas Panagiotakis September 11, 2012
Hi,

I'm having a problem regarding the use of simpliciTI and the extension pins of the board. The project requires both boards the first one, winch is connected to the computer, sends to the other board a message which the user writes through putty. The other board which receives the message, has to read it and toggle the on board red led and the p2.3 pin. The problem is that even though the red led on the board does what it is supposed to do, the p2.3 pin does not change its state (stays at low state). Below is the code that I used:

#include "bsp.h"
#include "mrfi.h"
#include "radios/family1/mrfi_spi.h"
#include "msp430x22x4.h"

void sleep(unsigned int count){
while(count > 0){
count--;
__no_operation();
__no_operation();
__no_operation();
__no_operation();
}
}

int main(){
P2DIR |= 0x08;
WDTCTL=WDTPW+WDTHOLD;
BSP_Init();
DCOCTL = CALDCO_8MHZ;
BCSCTL1 = CALBC1_8MHZ;
UCA0CTL1 = UCSSEL_2;
UCA0BR0 = 0x41;
UCA0BR1 = 0x3;
UCA0MCTL = UCBRS1 + UCBRS0;
UCA0CTL1 &= ~UCSWRST;
IE2 |= UCA0RXIE;
MRFI_Init();
MRFI_WakeUp();
MRFI_RxOn();
__bis_SR_register(GIE);
while(1){
sleep(60000);
sleep(60000);
P1OUT ^= 0x02;
sleep(60000);
sleep(60000);
}
}

void MRFI_RxCompleteISR(){
char msg[4];
mrfiPacket_t packet;
MRFI_Receive(&packet);
msg[0] = packet.frame[9];
msg[1] = packet.frame[10];
msg[2] = ':';
msg[3] = ')';
if (msg[0] == 'd' && msg[1] == '1'){
P1OUT ^= 0x01;
P2OUT ^= 0x08;
}
if (msg[0] == 'd' && msg[1 ]== '2'){
P2OUT ^= 0x08;
}
}

What am I doing wrong? I really need to toggle the p2.3 extension pin. Any suggestion is welcome!

Thank you in advance.

Beginning Microcontrollers with the MSP430

Kostas,

What port pin is connected to the red led?

Emmett Redd Ph.D. mailto:E...@missouristate.edu
Professor (417)836-5221
Department of Physics, Astronomy, and Materials Science
Missouri State University Fax (417)836-6226
901 SOUTH NATIONAL Lab (417)836-3770
SPRINGFIELD, MO 65897 USA Dept (417)836-5131

In statesmanship get the formalities right, never mind about the moralities. -- Mark Twain.
________________________________________
From: m... [m...] On Behalf Of Kostas Panagiotakis [p...@yahoo.com]
Sent: Tuesday, September 11, 2012 4:47 AM
To: m...
Subject: [msp430] ez430-RF2500 simpliciTI and GPIO problem

Hi,

I'm having a problem regarding the use of simpliciTI and the extension pins of the board. The project requires both boards the first one, winch is connected to the computer, sends to the other board a message which the user writes through putty. The other board which receives the message, has to read it and toggle the on board red led and the p2.3 pin. The problem is that even though the red led on the board does what it is supposed to do, the p2.3 pin does not change its state (stays at low state). Below is the code that I used:

#include "bsp.h"
#include "mrfi.h"
#include "radios/family1/mrfi_spi.h"
#include "msp430x22x4.h"

void sleep(unsigned int count){
while(count > 0){
count--;
__no_operation();
__no_operation();
__no_operation();
__no_operation();
}
}

int main(){
P2DIR |= 0x08;
WDTCTL=WDTPW+WDTHOLD;
BSP_Init();
DCOCTL = CALDCO_8MHZ;
BCSCTL1 = CALBC1_8MHZ;
UCA0CTL1 = UCSSEL_2;
UCA0BR0 = 0x41;
UCA0BR1 = 0x3;
UCA0MCTL = UCBRS1 + UCBRS0;
UCA0CTL1 &= ~UCSWRST;
IE2 |= UCA0RXIE;
MRFI_Init();
MRFI_WakeUp();
MRFI_RxOn();
__bis_SR_register(GIE);
while(1){
sleep(60000);
sleep(60000);
P1OUT ^= 0x02;
sleep(60000);
sleep(60000);
}
}

void MRFI_RxCompleteISR(){
char msg[4];
mrfiPacket_t packet;
MRFI_Receive(&packet);
msg[0] = packet.frame[9];
msg[1] = packet.frame[10];
msg[2] = ':';
msg[3] = ')';
if (msg[0] == 'd' && msg[1] == '1'){
P1OUT ^= 0x01;
P2OUT ^= 0x08;
}
if (msg[0] == 'd' && msg[1 ]== '2'){
P2OUT ^= 0x08;
}
}

What am I doing wrong? I really need to toggle the p2.3 extension pin. Any suggestion is welcome!

Thank you in advance.



Professor,

The red led is connected to p1.1 pin

--- In m..., "Redd, Emmett R" wrote:
>
> Kostas,
>
> What port pin is connected to the red led?
>
> Emmett Redd Ph.D. mailto:EmmettRedd@...
> Professor (417)836-5221
> Department of Physics, Astronomy, and Materials Science
> Missouri State University Fax (417)836-6226
> 901 SOUTH NATIONAL Lab (417)836-3770
> SPRINGFIELD, MO 65897 USA Dept (417)836-5131
>
> In statesmanship get the formalities right, never mind about the moralities. -- Mark Twain.

Kostas,

I note that your main toggles the red LED on P1.1 whether you are receiving the message or exercising the ISR or not.

Emmett Redd, Ph.D., Professor mailto:E...@MissouriState.Edu
Physics, Astronomy, and Materials Science Office: 417-836-5221
Missouri State University Dept: 417-838-5131
901 S NATIONAL AVENUE FAX: 417-836-6226
SPRINGFIELD, MO 65897 USA Lab: 417-836-3770

It is clear that thought is not free if the profession of certain opinions make it impossible to earn a living. -- Bertrand Russell

> -----Original Message-----
> From: m... [mailto:m...] On Behalf
> Of Kostas Panagiotakis
> Sent: Tuesday, September 11, 2012 4:48 AM
> To: m...
> Subject: [msp430] ez430-RF2500 simpliciTI and GPIO problem
>
> Hi,
>
> I'm having a problem regarding the use of simpliciTI and the extension
> pins of the board. The project requires both boards the first one,
> winch is connected to the computer, sends to the other board a message
> which the user writes through putty. The other board which receives the
> message, has to read it and toggle the on board red led and the p2.3
> pin. The problem is that even though the red led on the board does what
> it is supposed to do, the p2.3 pin does not change its state (stays at
> low state). Below is the code that I used:
>
> #include "bsp.h"
> #include "mrfi.h"
> #include "radios/family1/mrfi_spi.h"
> #include "msp430x22x4.h"
>
> void sleep(unsigned int count){
> while(count > 0){
> count--;
> __no_operation();
> __no_operation();
> __no_operation();
> __no_operation();
> }
> }
>
> int main(){
> P2DIR |= 0x08;
> WDTCTL=WDTPW+WDTHOLD;
> BSP_Init();
> DCOCTL = CALDCO_8MHZ;
> BCSCTL1 = CALBC1_8MHZ;
> UCA0CTL1 = UCSSEL_2;
> UCA0BR0 = 0x41;
> UCA0BR1 = 0x3;
> UCA0MCTL = UCBRS1 + UCBRS0;
> UCA0CTL1 &= ~UCSWRST;
> IE2 |= UCA0RXIE;
> MRFI_Init();
> MRFI_WakeUp();
> MRFI_RxOn();
> __bis_SR_register(GIE);
> while(1){
> sleep(60000);
> sleep(60000);
> P1OUT ^= 0x02;
> sleep(60000);
> sleep(60000);
> }
> }
>
> void MRFI_RxCompleteISR(){
> char msg[4];
> mrfiPacket_t packet;
> MRFI_Receive(&packet);
> msg[0] = packet.frame[9];
> msg[1] = packet.frame[10];
> msg[2] = ':';
> msg[3] = ')';
> if (msg[0] == 'd' && msg[1] == '1'){
> P1OUT ^= 0x01;
> P2OUT ^= 0x08;
> }
> if (msg[0] == 'd' && msg[1 ]== '2'){
> P2OUT ^= 0x08;
> }
> }
>
> What am I doing wrong? I really need to toggle the p2.3 extension pin.
> Any suggestion is welcome!
>
> Thank you in advance.
>
>
Professor,

I think you are referring to the while statement in main. The led that is toggle there is the green led which is located to the p1.2 pin on the board. I do this in order to check if the program freezes for any reason. The p1.1 pin is toggled only in the ISR (P1OUT ^=0x01;). This part works fine, the problem is the next statement (P2OUT ^= 0x08;) which does not seem to work correctly (no toggle).

--- In m..., "Redd, Emmett R" wrote:
>
> Kostas,
>
> I note that your main toggles the red LED on P1.1 whether you are receiving the message or exercising the ISR or not.
>
> Emmett Redd, Ph.D., Professor mailto:EmmettRedd@...
> Physics, Astronomy, and Materials Science Office: 417-836-5221
> Missouri State University Dept: 417-838-5131
> 901 S NATIONAL AVENUE FAX: 417-836-6226
> SPRINGFIELD, MO 65897 USA Lab: 417-836-3770
>
> It is clear that thought is not free if the profession of certain opinions make it impossible to earn a living. -- Bertrand Russell

Kostas,

I am sorry; I misread your code.

BTW, it would help if you did not delete your previous messages from your latter replies.

Emmett Redd, Ph.D., Professor mailto:E...@MissouriState.Edu
Physics, Astronomy, and Materials Science Office: 417-836-5221
Missouri State University Dept: 417-838-5131
901 S NATIONAL AVENUE FAX: 417-836-6226
SPRINGFIELD, MO 65897 USA Lab: 417-836-3770

It is clear that thought is not free if the profession of certain opinions make it impossible to earn a living. -- Bertrand Russell

> -----Original Message-----
> From: m... [mailto:m...] On Behalf
> Of Kostas Panagiotakis
> Sent: Tuesday, September 11, 2012 12:41 PM
> To: m...
> Subject: [msp430] Re: ez430-RF2500 simpliciTI and GPIO problem
>
> Professor,
>
> I think you are referring to the while statement in main. The led that
> is toggle there is the green led which is located to the p1.2 pin on
> the board. I do this in order to check if the program freezes for any
> reason. The p1.1 pin is toggled only in the ISR (P1OUT ^=0x01;). This
> part works fine, the problem is the next statement (P2OUT ^= 0x08;)
> which does not seem to work correctly (no toggle).
>
> --- In m..., "Redd, Emmett R" wrote:
> >
> > Kostas,
> >
> > I note that your main toggles the red LED on P1.1 whether you are
> receiving the message or exercising the ISR or not.
> >
> > Emmett Redd, Ph.D., Professor mailto:EmmettRedd@...
> > Physics, Astronomy, and Materials Science Office: 417-836-5221
> > Missouri State University Dept: 417-838-5131
> > 901 S NATIONAL AVENUE FAX: 417-836-6226
> > SPRINGFIELD, MO 65897 USA Lab: 417-836-3770
> >
> > It is clear that thought is not free if the profession of certain
> opinions make it impossible to earn a living. -- Bertrand Russell
>
>
Redd, Emmett R wrote:
> Kostas,
>
> I am sorry; I misread your code.
>
> BTW, it would help if you did not delete your previous messages from your latter replies.

Hi Redd,
I was going to post, but I can't help it now...

Do look at his code/first post. How is it possible that he sees toggles
on p1.0, which is how his code reads. Where is the:
P1DIR |= BIT0;

And what the hell is this?:

if (msg[0] == 'd' && msg[1] == '1'){
P1OUT ^= 0x01;
P2OUT ^= 0x08;
}
if (msg[0] == 'd' && msg[1 ]== '2'){
P2OUT ^= 0x08;
}

Why not set and reset? This has got to create confusing observations. Something is not right with Kostas' post; but then I haven't done any coding for several months...

Best, Dan.
--
"If they can get you asking the wrong questions, they dont
have to worry about answers."

-- Thomas Pynchon

In order to make a port-x pin-y "toggle", doing a "PxOUT ^= BITy;" may not be sufficient.

You need to set up that pin as digital output pin so that it will follow the state of PxOUT. And I do not know if you did that for P2.3 or not.

You usually need to check the setup of Comparator, Amplifier, ADC and DAC to make sure that pin is not used as analog I/O. You also need to make sure that the PxSEL and PxSEL2 bits are cleared. And finally, you have to set the PxDIR bits. Without the above, PxOUT may have no influence on what is the state of that pin@

--- In m..., "Kostas Panagiotakis" wrote:
>
> Hi,
>
> I'm having a problem regarding the use of simpliciTI and the extension pins of the board. The project requires both boards the first one, winch is connected to the computer, sends to the other board a message which the user writes through putty. The other board which receives the message, has to read it and toggle the on board red led and the p2.3 pin. The problem is that even though the red led on the board does what it is supposed to do, the p2.3 pin does not change its state (stays at low state). Below is the code that I used:
>
> #include "bsp.h"
> #include "mrfi.h"
> #include "radios/family1/mrfi_spi.h"
> #include "msp430x22x4.h"
>
> void sleep(unsigned int count){
> while(count > 0){
> count--;
> __no_operation();
> __no_operation();
> __no_operation();
> __no_operation();
> }
> }
>
> int main(){
> P2DIR |= 0x08;
> WDTCTL=WDTPW+WDTHOLD;
> BSP_Init();
> DCOCTL = CALDCO_8MHZ;
> BCSCTL1 = CALBC1_8MHZ;
> UCA0CTL1 = UCSSEL_2;
> UCA0BR0 = 0x41;
> UCA0BR1 = 0x3;
> UCA0MCTL = UCBRS1 + UCBRS0;
> UCA0CTL1 &= ~UCSWRST;
> IE2 |= UCA0RXIE;
> MRFI_Init();
> MRFI_WakeUp();
> MRFI_RxOn();
> __bis_SR_register(GIE);
> while(1){
> sleep(60000);
> sleep(60000);
> P1OUT ^= 0x02;
> sleep(60000);
> sleep(60000);
> }
> }
>
> void MRFI_RxCompleteISR(){
> char msg[4];
> mrfiPacket_t packet;
> MRFI_Receive(&packet);
> msg[0] = packet.frame[9];
> msg[1] = packet.frame[10];
> msg[2] = ':';
> msg[3] = ')';
> if (msg[0] == 'd' && msg[1] == '1'){
> P1OUT ^= 0x01;
> P2OUT ^= 0x08;
> }
> if (msg[0] == 'd' && msg[1 ]== '2'){
> P2OUT ^= 0x08;
> }
> }
>
> What am I doing wrong? I really need to toggle the p2.3 extension pin. Any suggestion is welcome!
>
> Thank you in advance.
>

What I am guessing is those are what he sending across the air waves and
this is the receiving end thus if the data was sent and received
correctly you would get a blinking light. I also agree that I
personally like P1OUT |= 0x01 / P1OUT &=~0x01 (prefer even further
P1OUT|=BIT0) because it is more explicit and you know what should
happen. I am also guessing this is a Homework assignment.

All the best,
Jake G.

On 9/11/2012 8:49 PM, Dan Bloomquist wrote:
> Redd, Emmett R wrote:
>> Kostas,
>>
>> I am sorry; I misread your code.
>>
>> BTW, it would help if you did not delete your previous messages from your latter replies.
> Hi Redd,
> I was going to post, but I can't help it now...
>
> Do look at his code/first post. How is it possible that he sees toggles
> on p1.0, which is how his code reads. Where is the:
> P1DIR |= BIT0;
>
> And what the hell is this?:
>
> if (msg[0] == 'd' && msg[1] == '1'){
> P1OUT ^= 0x01;
> P2OUT ^= 0x08;
> }
> if (msg[0] == 'd' && msg[1 ]== '2'){
> P2OUT ^= 0x08;
> }
>
> Why not set and reset? This has got to create confusing observations. Something is not right with Kostas' post; but then I haven't done any coding for several months...
>
> Best, Dan.


The 2024 Embedded Online Conference