Sign in

username:

password:



Not a member?

Search msp430



Search tips

Subscribe to msp430



Ads

Discussion Groups

Discussion Groups | MSP430 | eZ430 data transfer within main code

The purpose of this group is to foster exchange of information on the Texas Instruments MSP430 family of microcontrollers and related tools. Everyone welcome, all levels of familiarity/expertise.

eZ430 data transfer within main code - randy ram - Aug 22 0:47:04 2008

I having problem sending the pulse count from Port2 into the main
program.

When the port see a high signal is only sends out 0's instead of
sending the number of count to the main program and then giving out
the right data.

I know for sure that the problem is in the ISR as I tried giving
constant number with the main for the count numbers and it will send
out the right value. And if I put a constant into the Vector 2 isr,
it still says 0.

Here are few snapshoots of the code.

Any help will be greatly appreciated.

Thanks

updateTach();

temp = results[1];
volt = (temp*25)/512;
rpm = (tachRPM)/100; //added for RPM test

msg[0] = degC&0xFF;
msg[1] = (degC>>8)&0xFF;
msg[2] = volt;
msg[3] = rpm;

void updateTach(void)
{

P2IE &= ~(TACH); // Disable tachometer
interrupt P2.0
_NOP(); // Wait 1 instruction cycle
// Convert pulse count to RPM
tachRPM = ((tachCount)/PULSESPERREVOLUTION)*60;
P2IE |= (TACH); // Re-enable tachometer
interrupt P2.0
tachCount = 0; // Reset the pulse counter
}
// PORT2 Interrupt Service Routine
#pragma vector=PORT2_VECTOR
__interrupt void isrPORT2(void)
{

if (P2IFG & TACH) { // Tachometer pulse detected
tachCount++; // Increment tach counter
P2IFG &= ~TACH; // Clear interrupt flag//Changed TACH
__bic_SR_register_on_exit(LPM3_bits); // Don't forget to exit the
low power mode.
MRFI_GpioIsr();
}
}

--
Be Yourself @ mail.com!
Choose From 200+ Email Addresses
Get a Free Account at www.mail.com

[Non-text portions of this message have been removed]
------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )


Re: eZ430 data transfer within main code - Greg Maki - Aug 22 9:15:54 2008

randy ram wrote:
> I having problem sending the pulse count from Port2 into the main
> program.
>
> When the port see a high signal is only sends out 0's instead of
> sending the number of count to the main program and then giving out
> the right data.
>
> I know for sure that the problem is in the ISR as I tried giving
> constant number with the main for the count numbers and it will send
> out the right value. And if I put a constant into the Vector 2 isr,
> it still says 0.
>
> Here are few snapshoots of the code.
>
> Any help will be greatly appreciated.
>
> Thanks
>
> updateTach();
>
> temp = results[1];
> volt = (temp*25)/512;
> rpm = (tachRPM)/100; //added for RPM test
>
> msg[0] = degC&0xFF;
> msg[1] = (degC>>8)&0xFF;
> msg[2] = volt;
> msg[3] = rpm;
>
> void updateTach(void)
> {
>
> P2IE &= ~(TACH); // Disable tachometer
> interrupt P2.0
> _NOP(); // Wait 1 instruction cycle
> // Convert pulse count to RPM
> tachRPM = ((tachCount)/PULSESPERREVOLUTION)*60;
> P2IE |= (TACH); // Re-enable tachometer
> interrupt P2.0
> tachCount = 0; // Reset the pulse counter
> }
>
> // PORT2 Interrupt Service Routine
> #pragma vector=PORT2_VECTOR
> __interrupt void isrPORT2(void)
> {
>
> if (P2IFG & TACH) { // Tachometer pulse detected
> tachCount++; // Increment tach counter
> P2IFG &= ~TACH; // Clear interrupt flag//Changed TACH
>
> __bic_SR_register_on_exit(LPM3_bits); // Don't forget to exit the
> low power mode.
> MRFI_GpioIsr();
> }
> }
>

Are you sure that your interrupt is firing? Is your port pin configured as an
input? Try setting a breakpoint and see if it gets hit. If that isn't possible,
try toggling an unused port pin in your ISR.

Another thing to check is the scope of your tachCount variable.

Best regards,

Greg

------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

RE: eZ430 data transfer within main code - Dan Muzzey - Aug 22 9:31:32 2008

Randy

Looking through the code I see several things that look a little
strange. Some of them are probably purely style differences. I'm not
sure what the line interrupt P2.0 does. Is it a continuation of the
comment from the line above?

Starting with the interrupt. If you put a breakpoint on this line:

tachCount++; // Increment tach counter

does the program stop?

Additionally, what type of variable is tachCount? I'm assuming it is a
global. However, we would write this as TachCount. The firmware
standard we abide by calls this out. That being said, it wouldn't
effect the program. However, is tachCount volatile? I'm thinking it
should be since it can change at any time.

If the program doesn't stop there then check the ISR setup, port setup,
and all that stuff. If it does stop then manually load tachCount with
some value. Does this wash through to the rest of the program?

I also noticed that if tachCount is less than PULSESPERREVOLUTION then
tachRPM is going to be zero.

One more style comment then I'll shut up about style.

P2IE &= ~(TACH); // Disable tachometer
interrupt P2.0
_NOP(); // Wait 1 instruction cycle
// Convert pulse count to RPM
tachRPM = ((tachCount)/PULSESPERREVOLUTION)*60;
P2IE |= (TACH); // Re-enable tachometer
interrupt P2.0
tachCount = 0; // Reset the pulse counter

Could be written a little clearer and have the interrupts disabled less
if you did it this way:

P2IE &= ~(TACH); // Disable tachometer
Tachcopy = tachCount;
tachCount = 0;
P2IE |= (TACH); // Re-enable tachometer

At this point proceed with the math. This is a pretty minor change but
it should make it more predictable in the amount of time the interrupts
will be disabled.

Dan

________________________________

From: m...@yahoogroups.com [mailto:m...@yahoogroups.com] On Behalf
Of randy ram
Sent: Thursday, August 21, 2008 11:47 PM
To: m...@yahoogroups.com
Subject: [msp430] eZ430 data transfer within main code

I having problem sending the pulse count from Port2 into the main
program.

When the port see a high signal is only sends out 0's instead of
sending the number of count to the main program and then giving out
the right data.

I know for sure that the problem is in the ISR as I tried giving
constant number with the main for the count numbers and it will send
out the right value. And if I put a constant into the Vector 2 isr,
it still says 0.

Here are few snapshoots of the code.

Any help will be greatly appreciated.

Thanks

updateTach();

temp = results[1];
volt = (temp*25)/512;
rpm = (tachRPM)/100; //added for RPM test

msg[0] = degC&0xFF;
msg[1] = (degC>>8)&0xFF;
msg[2] = volt;
msg[3] = rpm;

void updateTach(void)
{

P2IE &= ~(TACH); // Disable tachometer
interrupt P2.0
_NOP(); // Wait 1 instruction cycle
// Convert pulse count to RPM
tachRPM = ((tachCount)/PULSESPERREVOLUTION)*60;
P2IE |= (TACH); // Re-enable tachometer
interrupt P2.0
tachCount = 0; // Reset the pulse counter
}

// PORT2 Interrupt Service Routine
#pragma vector=PORT2_VECTOR
__interrupt void isrPORT2(void)
{

if (P2IFG & TACH) { // Tachometer pulse detected
tachCount++; // Increment tach counter
P2IFG &= ~TACH; // Clear interrupt flag//Changed TACH

__bic_SR_register_on_exit(LPM3_bits); // Don't forget to exit the
low power mode.
MRFI_GpioIsr();
}
}

--
Be Yourself @ mail.com!
Choose From 200+ Email Addresses
Get a Free Account at www.mail.com

[Non-text portions of this message have been removed]

[Non-text portions of this message have been removed]
------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: eZ430 data transfer within main code - randy ram - Aug 22 12:24:51 2008

As far I know, I believe the interupt is working. Because, when touch the
port2.0, it transmits the number to the receiver. Because when I actually
put a constant into the main program, and start playing port2.0, it fires
the number out to the receiver.But when I plug the same number into the
PORT2 Interupt section, it just sends me 0. Somehow the tachCount++ is
not happennig or it more likely it is not sent into updateTach(). Randy

----- Original Message -----
From: "Greg Maki"
To: m...@yahoogroups.com
Subject: Re: [msp430] eZ430 data transfer within main code
Date: Fri, 22 Aug 2008 09:15:43 -0400

randy ram wrote:
>
>
> I having problem sending the pulse count from Port2 into the main
> program.
>
> When the port see a high signal is only sends out 0's instead of
> sending the number of count to the main program and then giving out
> the right data.
>
> I know for sure that the problem is in the ISR as I tried giving
> constant number with the main for the count numbers and it will
send
> out the right value. And if I put a constant into the Vector 2 isr,
> it still says 0.
>
> Here are few snapshoots of the code.
>
> Any help will be greatly appreciated.
>
> Thanks
>
> updateTach();
>
> temp = results[1];
> volt = (temp*25)/512;
> rpm = (tachRPM)/100; //added for RPM test
>
> msg[0] = degC&0xFF;
> msg[1] = (degC>>8)&0xFF;
> msg[2] = volt;
> msg[3] = rpm;
>
> void updateTach(void)
> {
>
> P2IE &= ~(TACH); // Disable tachometer
> interrupt P2.0
> _NOP(); // Wait 1 instruction cycle
> // Convert pulse count to RPM
> tachRPM = ((tachCount)/PULSESPERREVOLUTION)*60;
> P2IE |= (TACH); // Re-enable tachometer
> interrupt P2.0
> tachCount = 0; // Reset the pulse counter
> }
>
> // PORT2 Interrupt Service Routine
> #pragma vector=PORT2_VECTOR
> __interrupt void isrPORT2(void)
> {
>
> if (P2IFG & TACH) { // Tachometer pulse detected
> tachCount++; // Increment tach counter
> P2IFG &= ~TACH; // Clear interrupt flag//Changed TACH
>
> __bic_SR_register_on_exit(LPM3_bits); // Don't forget to exit the
> low power mode.
> MRFI_GpioIsr();
> }
> }
>

Are you sure that your interrupt is firing? Is your port pin
configured as an
input? Try setting a breakpoint and see if it gets hit. If that isn't
possible,
try toggling an unused port pin in your ISR.

Another thing to check is the scope of your tachCount variable.

Best regards,

Greg

--
Be Yourself @ mail.com!
Choose From 200+ Email Addresses
Get a Free Account at www.mail.com

[Non-text portions of this message have been removed]
------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

RE: eZ430 data transfer within main code - randy ram - Aug 22 12:24:51 2008

All Port2.0 needs to do is take then umber of pulses (rising edge) that
arrive from a sensor within a certain time. Then I am converting it into
RPM. When I actually to place a constant(tachCount) outside of the Port2
Interupt Script, the RPM does show up at the receiving end with no
problem. And when I place the same constant into the Port2 Interupt
Script, I get 0000.And yes, if number is less then PULSEPERREVOLUTION,
then number will be 0. Which I am okay with. Here is the know code. I
know it is a little long but if you could just take a look at the just
the TACH sections , it would be great.
#include "bsp.h"
#include "mrfi.h"
#include "mrfi_defs.h"
#include "nwk_types.h"
#include "nwk_api.h"
#include "bsp_leds.h"
#include "bsp_buttons.h"
#include "vlo_rand.h"
#include "msp430x22x4.h"void linkTo(void);
void MCU_Init(void);
void updateTach(void);__no_init volatile int tempOffset @ 0x10F4; //
Temperature offset set at production
__no_init volatile char Flash_Addr[4] @ 0x10F0; // Flash address set
randomlyvoid createRandomAddress(); //Version: ED_rr1.1. addition
// Port2 Pin Configuration
int PULSESPERREVOLUTION = 1; // Frequency of sample point
in a rev
unsigned int tachCount = 0; // Count revolutions of fan
unsigned int tachRPM = 0; // Stores RPM of fan
unsigned int lastRPM = 0; // Stores RPM of last reading
//Version: ED_rr1.1. addition ended
void main (void)
{
addr_t lAddr;
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
{
// delay loop to ensure proper startup before SimpliciTI increases DCO
// This is typically tailored to the power supply used, and in this case
// is overkill for safety due to wide distribution.
volatile int i;
for(i = 0; i < 0xFFFF; i++){}
}
if( CALBC1_8MHZ == 0xFF ) // Do not run if cal values are
erased
{
volatile int i;
P1DIR |= 0x03;
BSP_TURN_ON_LED1();
BSP_TURN_OFF_LED2();
while(1)
{
for(i = 0; i < 0x5FFF; i++){}
BSP_TOGGLE_LED2();
BSP_TOGGLE_LED1();
}
}

// SimpliciTI will change port pin settings as well
// SimpliciTI will change port pin settings as well
P1DIR = 0xFF;
P1OUT = 0x00;
//P2DIR = 0x26; // 100110 where Port2.0 is input. Is this right?
P2OUT = 0x00; // no output selected. Is this right?
//P2IE |= 0x01; // P2.0 interrupt enabled
//P2IES |= 0x01; // P2.0 Hi/lo edge
//P2IFG &= ~0x01; // P2.0 IFG cleared
P3DIR = 0xC0;
P3OUT = 0x00;
P4DIR = 0xFF;
P4OUT = 0x00;
P2DIR &= ~0x07; // P2.0-P2.2 as input
P2IE |= 0x07; // P2.0-p2.2 interrupt enabled
P2IES &= ~0x07; // P2.0-p2.2 lo/Hi edge
P2IFG &= ~0x07; // P2.0-P2.2 IFG cleared

if( Flash_Addr[0] == 0xFF &&
Flash_Addr[1] == 0xFF &&
Flash_Addr[2] == 0xFF &&
Flash_Addr[3] == 0xFF )
{
createRandomAddress(); // set Random device address at
initial startup
}
lAddr.addr[0]=Flash_Addr[0];
lAddr.addr[1]=Flash_Addr[1];
lAddr.addr[2]=Flash_Addr[2];
lAddr.addr[3]=Flash_Addr[3];
SMPL_Ioctl(IOCTL_OBJ_ADDR, IOCTL_ACT_SET, &lAddr);
BCSCTL1 = CALBC1_8MHZ; // Set DCO after random
function
DCOCTL = CALDCO_8MHZ;

BCSCTL3 |= LFXT1S_2; // LFXT1 = VLO
TACCTL0 = CCIE; // TACCR0 interrupt enabled
TACCR0 = 12000; // ~ 1 sec
TACTL = TASSEL_1 + MC_1; // ACLK, upmode

// keep trying to join until successful. toggle LEDS to indicate that
// joining has not occurred. LED3 is red but labeled LED 4 on the EXP
// board silkscreen. LED1 is green.
while (SMPL_NO_JOIN == SMPL_Init((uint8_t (*)(linkID_t))0))
{
BSP_TOGGLE_LED1();
BSP_TOGGLE_LED2();;
__bis_SR_register(LPM3_bits + GIE); // LPM3 with interrupts enabled
}
// unconditional link to AP which is listening due to successful join.
linkTo();}void createRandomAddress()
{
unsigned int rand, rand2;
do
{
rand = TI_getRandomIntegerFromVLO(); // first byte can not be 0x00 of
0xFF
}
while( (rand & 0xFF00)==0xFF00 || (rand & 0xFF00)==0x0000 );
rand2 = TI_getRandomIntegerFromVLO();

BCSCTL1 = CALBC1_1MHZ; // Set DCO to 1MHz
DCOCTL = CALDCO_1MHZ;
FCTL2 = FWKEY + FSSEL0 + FN1; // MCLK/3 for Flash Timing
Generator
FCTL3 = FWKEY + LOCKA; // Clear LOCK & LOCKA bits
FCTL1 = FWKEY + WRT; // Set WRT bit for write
operation Flash_Addr[0]=(rand>>8) & 0xFF;
Flash_Addr[1]=rand & 0xFF;
Flash_Addr[2]=(rand2>>8) & 0xFF;
Flash_Addr[3]=rand2 & 0xFF;

FCTL1 = FWKEY; // Clear WRT bit
FCTL3 = FWKEY + LOCKA + LOCK; // Set LOCK & LOCKA bit
}void linkTo()
{

linkID_t linkID1;
uint8_t msg[4];//changed from 3 to 4 060108RR // keep trying to link...
while (SMPL_SUCCESS != SMPL_Link(&linkID1))
{
__bis_SR_register(LPM3_bits + GIE); // LPM3 with interrupts enabled
BSP_TOGGLE_LED1();
BSP_TOGGLE_LED2();
}

// Turn off all LEDs
if (BSP_LED1_IS_ON())
{
BSP_TOGGLE_LED1();
}
if (BSP_LED2_IS_ON())
{
BSP_TOGGLE_LED2();
}
while (1)
{
volatile long temp;
int degC, volt, rpm;
int results[3];
SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_SLEEP, "" );
__bis_SR_register(LPM3_bits+GIE); // LPM3 with interrupts enabled
SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_AWAKE, "" );

BSP_TOGGLE_LED2();
ADC10CTL1 = INCH_10 + ADC10DIV_4; // Temp Sensor ADC10CLK/5
ADC10CTL0 = SREF_1 + ADC10SHT_3 + REFON + ADC10ON + ADC10IE + ADC10SR;
for( degC = 240; degC > 0; degC-- ); // delay to allow reference to
settle
ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
__bis_SR_register(CPUOFF + GIE); // LPM0 with interrupts enabled
results[0] = ADC10MEM;

ADC10CTL0 &= ~ENC;

ADC10CTL1 = INCH_11; // AVcc/2
ADC10CTL0 = SREF_1 + ADC10SHT_2 + REFON + ADC10ON + ADC10IE + REF2_5V;
for( degC = 240; degC > 0; degC-- ); // delay to allow reference to
settle
ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
__bis_SR_register(CPUOFF + GIE); // LPM0 with interrupts enabled
results[1] = ADC10MEM;
ADC10CTL0 &= ~ENC;
ADC10CTL0 &= ~(REFON + ADC10ON); // turn off A/D to save power

// oC = ((A10/1024)*1500mV)-986mV)*1/3.55mV = A10*423/1024 - 278
// the temperature is transmitted as an integer where 32.1 = 321
// hence 4230 instead of 423

updateTach();

temp = results[0];
degC = ((temp - 673) * 4230) / 1024;

if( tempOffset != 0xFFFF )
{
degC += tempOffset;
}
/*message format, UB = upper Byte, LB = lower Byte
-------------------------------
|degC LB | degC UB | volt LB |
-------------------------------
0 1 2
*/

temp = results[1];
volt = (temp*25)/512;
rpm = (tachRPM)/100; //added for RPM test

msg[0] = degC&0xFF;
msg[1] = (degC>>8)&0xFF;
msg[2] = volt;
msg[3] = rpm; if (SMPL_SUCCESS == SMPL_Send(linkID1, msg, sizeof(msg)))
{
BSP_TOGGLE_LED2();
}
else
{
BSP_TOGGLE_LED2();
BSP_TOGGLE_LED1();
}
}
}
//Version: ED_rr1.1. addition
void updateTach(void)
{

P2IE &= ~(TACH); // Disable tachometer interrupt
P2.0
_NOP(); // Wait 1 instruction cycle
// Convert pulse count to RPM
tachRPM = ((tachCount)/PULSESPERREVOLUTION)*60;
P2IE |= (TACH); // Re-enable tachometer
interrupt P2.0
tachCount = 0; // Reset the pulse counter
}void refreshTach()
{
//if (tachRPM == 0) // Check if fan(s) stopped
//setStatusLED(ALARM); // Set ALARM LED
//else
//setStatusLED(OK); // Clear ALARM LED
updateTach(); // Refresh tachometer readings
//displayTach(tachRPM); // Display RPM on LCD //if
(tachRPM > lastRPM) // Check if current RPM > last
//displayUpArrow(); // Yes, display UP arrow
//else
//displayDownArrow(); // No, display DOWN arrow
//lastRPM = tachRPM; // Save RPM history for
future
}
/*------------------------------------------------------------------------------
* ADC10 interrupt service routine
------------------------------------------------------------------------------*/
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR(void)
{
__bic_SR_register_on_exit(CPUOFF); // Clear CPUOFF bit from 0(SR)
}/*------------------------------------------------------------------------------
* Timer A0 interrupt service routine
------------------------------------------------------------------------------*/
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
__bic_SR_register_on_exit(LPM3_bits); // Clear LPM3 bit from 0(SR)
} // PORT2 Interrupt Service Routine
#pragma vector=PORT2_VECTOR
__interrupt void isrPORT2(void)
{

if (P2IFG & TACH) { // Tachometer pulse detected
tachCount++; // Increment tach counter
P2IFG &= ~TACH; // Clear interrupt flag//Changed TACH
__bic_SR_register_on_exit(LPM3_bits); // Don't forget to exit the low
power mode.
MRFI_GpioIsr();
}
}
//Version: ED_rr1.1. addition END ThanksRandy

----- Original Message -----
From: "Dan Muzzey"
To: m...@yahoogroups.com
Subject: RE: [msp430] eZ430 data transfer within main code
Date: Fri, 22 Aug 2008 08:31:24 -0500

Randy

Looking through the code I see several things that look a little
strange. Some of them are probably purely style differences. I'm not
sure what the line interrupt P2.0 does. Is it a continuation of the
comment from the line above?

Starting with the interrupt. If you put a breakpoint on this line:

tachCount++; // Increment tach counter

does the program stop?

Additionally, what type of variable is tachCount? I'm assuming it is
a
global. However, we would write this as TachCount. The firmware
standard we abide by calls this out. That being said, it wouldn't
effect the program. However, is tachCount volatile? I'm thinking it
should be since it can change at any time.

If the program doesn't stop there then check the ISR setup, port
setup,
and all that stuff. If it does stop then manually load tachCount with
some value. Does this wash through to the rest of the program?

I also noticed that if tachCount is less than PULSESPERREVOLUTION
then
tachRPM is going to be zero.

One more style comment then I'll shut up about style.

P2IE &= ~(TACH); // Disable tachometer
interrupt P2.0
_NOP(); // Wait 1 instruction cycle
// Convert pulse count to RPM
tachRPM = ((tachCount)/PULSESPERREVOLUTION)*60;
P2IE |= (TACH); // Re-enable tachometer
interrupt P2.0
tachCount = 0; // Reset the pulse counter

Could be written a little clearer and have the interrupts disabled
less
if you did it this way:

P2IE &= ~(TACH); // Disable tachometer
Tachcopy = tachCount;
tachCount = 0;
P2IE |= (TACH); // Re-enable tachometer

At this point proceed with the math. This is a pretty minor change
but
it should make it more predictable in the amount of time the
interrupts
will be disabled.

Dan

________________________________

From: m...@yahoogroups.com [mailto:m...@yahoogroups.com] On
Behalf
Of randy ram
Sent: Thursday, August 21, 2008 11:47 PM
To: m...@yahoogroups.com
Subject: [msp430] eZ430 data transfer within main code

I having problem sending the pulse count from Port2 into the main
program.

When the port see a high signal is only sends out 0's instead of
sending the number of count to the main program and then giving out
the right data.

I know for sure that the problem is in the ISR as I tried giving
constant number with the main for the count numbers and it will send
out the right value. And if I put a constant into the Vector 2 isr,
it still says 0.

Here are few snapshoots of the code.

Any help will be greatly appreciated.

Thanks

updateTach();

temp = results[1];
volt = (temp*25)/512;
rpm = (tachRPM)/100; //added for RPM test

msg[0] = degC&0xFF;
msg[1] = (degC>>8)&0xFF;
msg[2] = volt;
msg[3] = rpm;

void updateTach(void)
{

P2IE &= ~(TACH); // Disable tachometer
interrupt P2.0
_NOP(); // Wait 1 instruction cycle
// Convert pulse count to RPM
tachRPM = ((tachCount)/PULSESPERREVOLUTION)*60;
P2IE |= (TACH); // Re-enable tachometer
interrupt P2.0
tachCount = 0; // Reset the pulse counter
}

// PORT2 Interrupt Service Routine
#pragma vector=PORT2_VECTOR
__interrupt void isrPORT2(void)
{

if (P2IFG & TACH) { // Tachometer pulse detected
tachCount++; // Increment tach counter
P2IFG &= ~TACH; // Clear interrupt flag//Changed TACH

__bic_SR_register_on_exit(LPM3_bits); // Don't forget to exit the
low power mode.
MRFI_GpioIsr();
}
}

--
Be Yourself @ mail.com!
Choose From 200+ Email Addresses
Get a Free Account at www.mail.com

[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]

--
Be Yourself @ mail.com!
Choose From 200+ Email Addresses
Get a Free Account at www.mail.com

[Non-text portions of this message have been removed]
------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

RE: eZ430 data transfer within main code - Andreas =?ISO-8859-1?Q?K=F6pke?= - Aug 22 12:49:05 2008

Please change the declaration to:
volatile unsigned int tachCount = 0; // Count revolutions of fan

AFAIK you are checking the variable in a loop. With some luck the
compiler managed to hold tachCount in one of its registers -- unaware
that it is changed outside the loop by an interrupt.

Be nice to your compiler and tell it that an interrupt changes the
variable.

Best, Andreas

------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

RE: eZ430 data transfer within main code - Dan Muzzey - Aug 22 12:54:59 2008

Couple items.

Drop a break point in the ISR. See if its getting triggered. It should
be triggered every time the input changes state. Then single step it
out. Bring up the variable in the watch window. Keep an eye on whats
doing it. I'm not sure your delay loops will work either. The compiler
may edit them out since they do not do anything obvious. Maybe someone
with a little more C insite can help. I think this line: for( degC =
240; degC > 0; degC-- ); // delay to allow reference to settle will be
optimized out. Declare decC as volatile. There are much better ways to
do delays as well. I didn't see any real time delays in the program.
It looks like its going to drop into the while loop in LinkTo(). If
this is so, UpdateTach is going to run pretty often. UpdateTach will
clear out the count every time. As someone else directed, tachCount
should be volatile. I think this will fix that problem but may uncover
a couple others.

Dan

________________________________

From: m...@yahoogroups.com [mailto:m...@yahoogroups.com] On Behalf
Of randy ram
Sent: Friday, August 22, 2008 9:33 AM
To: m...@yahoogroups.com
Subject: RE: [msp430] eZ430 data transfer within main code

All Port2.0 needs to do is take then umber of pulses (rising edge) that
arrive from a sensor within a certain time. Then I am converting it into
RPM. When I actually to place a constant(tachCount) outside of the Port2
Interupt Script, the RPM does show up at the receiving end with no
problem. And when I place the same constant into the Port2 Interupt
Script, I get 0000.And yes, if number is less then PULSEPERREVOLUTION,
then number will be 0. Which I am okay with. Here is the know code. I
know it is a little long but if you could just take a look at the just
the TACH sections , it would be great.
#include "bsp.h"
#include "mrfi.h"
#include "mrfi_defs.h"
#include "nwk_types.h"
#include "nwk_api.h"
#include "bsp_leds.h"
#include "bsp_buttons.h"
#include "vlo_rand.h"
#include "msp430x22x4.h"void linkTo(void);
void MCU_Init(void);
void updateTach(void);__no_init volatile int tempOffset @ 0x10F4; //
Temperature offset set at production
__no_init volatile char Flash_Addr[4] @ 0x10F0; // Flash address set
randomlyvoid createRandomAddress(); //Version: ED_rr1.1. addition
// Port2 Pin Configuration
int PULSESPERREVOLUTION = 1; // Frequency of sample point
in a rev
unsigned int tachCount = 0; // Count revolutions of fan
unsigned int tachRPM = 0; // Stores RPM of fan
unsigned int lastRPM = 0; // Stores RPM of last reading
//Version: ED_rr1.1. addition ended

void main (void)
{
addr_t lAddr;
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
{
// delay loop to ensure proper startup before SimpliciTI increases
DCO
// This is typically tailored to the power supply used, and in
this case
// is overkill for safety due to wide distribution.
volatile int i;
for(i = 0; i < 0xFFFF; i++)

{}
}
if( CALBC1_8MHZ == 0xFF ) // Do not run if cal values are
erased
{
volatile int i;
P1DIR |= 0x03;
BSP_TURN_ON_LED1();
BSP_TURN_OFF_LED2();
while(1)
{
for(i = 0; i < 0x5FFF; i++){}
BSP_TOGGLE_LED2();
BSP_TOGGLE_LED1();
}
}

// SimpliciTI will change port pin settings as well
// SimpliciTI will change port pin settings as well
P1DIR = 0xFF;
P1OUT = 0x00;
//P2DIR = 0x26; // 100110 where Port2.0 is input. Is this right?
P2OUT = 0x00; // no output selected. Is this right?
//P2IE |= 0x01; // P2.0 interrupt enabled
//P2IES |= 0x01; // P2.0 Hi/lo edge
//P2IFG &= ~0x01; // P2.0 IFG cleared
P3DIR = 0xC0;
P3OUT = 0x00;
P4DIR = 0xFF;
P4OUT = 0x00;
P2DIR &= ~0x07; // P2.0-P2.2 as input
P2IE |= 0x07; // P2.0-p2.2 interrupt enabled
P2IES &= ~0x07; // P2.0-p2.2 lo/Hi edge
P2IFG &= ~0x07; // P2.0-P2.2 IFG cleared

if( Flash_Addr[0] == 0xFF &&
Flash_Addr[1] == 0xFF &&
Flash_Addr[2] == 0xFF &&
Flash_Addr[3] == 0xFF )
{
createRandomAddress(); // set Random device address at
initial startup
}
lAddr.addr[0]=Flash_Addr[0];
lAddr.addr[1]=Flash_Addr[1];
lAddr.addr[2]=Flash_Addr[2];
lAddr.addr[3]=Flash_Addr[3];
SMPL_Ioctl(IOCTL_OBJ_ADDR, IOCTL_ACT_SET, &lAddr);
BCSCTL1 = CALBC1_8MHZ; // Set DCO after random
function
DCOCTL = CALDCO_8MHZ;

BCSCTL3 |= LFXT1S_2; // LFXT1 = VLO
TACCTL0 = CCIE; // TACCR0 interrupt enabled
TACCR0 = 12000; // ~ 1 sec
TACTL = TASSEL_1 + MC_1; // ACLK, upmode

// keep trying to join until successful. toggle LEDS to indicate that
// joining has not occurred. LED3 is red but labeled LED 4 on the EXP
// board silkscreen. LED1 is green.
while (SMPL_NO_JOIN == SMPL_Init((uint8_t (*)(linkID_t))0))
{
BSP_TOGGLE_LED1();
BSP_TOGGLE_LED2();;
__bis_SR_register(LPM3_bits + GIE); // LPM3 with interrupts enabled
}
// unconditional link to AP which is listening due to successful join.
linkTo();}void createRandomAddress()
{
unsigned int rand, rand2;
do
{
rand = TI_getRandomIntegerFromVLO(); // first byte can not be 0x00 of
0xFF
}
while( (rand & 0xFF00)==0xFF00 || (rand & 0xFF00)==0x0000 );
rand2 = TI_getRandomIntegerFromVLO();

BCSCTL1 = CALBC1_1MHZ; // Set DCO to 1MHz
DCOCTL = CALDCO_1MHZ;
FCTL2 = FWKEY + FSSEL0 + FN1; // MCLK/3 for Flash Timing
Generator
FCTL3 = FWKEY + LOCKA; // Clear LOCK & LOCKA bits
FCTL1 = FWKEY + WRT; // Set WRT bit for write
operation Flash_Addr[0]=(rand>>8) & 0xFF;
Flash_Addr[1]=rand & 0xFF;
Flash_Addr[2]=(rand2>>8) & 0xFF;
Flash_Addr[3]=rand2 & 0xFF;

FCTL1 = FWKEY; // Clear WRT bit
FCTL3 = FWKEY + LOCKA + LOCK; // Set LOCK & LOCKA bit
}void linkTo()
{

linkID_t linkID1;
uint8_t msg[4];//changed from 3 to 4 060108RR // keep trying to link...
while (SMPL_SUCCESS != SMPL_Link(&linkID1))
{
__bis_SR_register(LPM3_bits + GIE); // LPM3 with interrupts enabled
BSP_TOGGLE_LED1();
BSP_TOGGLE_LED2();
}

// Turn off all LEDs
if (BSP_LED1_IS_ON())
{
BSP_TOGGLE_LED1();
}
if (BSP_LED2_IS_ON())
{
BSP_TOGGLE_LED2();
}
while (1)
{
volatile long temp;
int degC, volt, rpm;
int results[3];
SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_SLEEP, "" );
__bis_SR_register(LPM3_bits+GIE); // LPM3 with interrupts enabled
SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_AWAKE, "" );

BSP_TOGGLE_LED2();
ADC10CTL1 = INCH_10 + ADC10DIV_4; // Temp Sensor ADC10CLK/5
ADC10CTL0 = SREF_1 + ADC10SHT_3 + REFON + ADC10ON + ADC10IE + ADC10SR;
for( degC = 240; degC > 0; degC-- ); // delay to allow reference to
settle
ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
__bis_SR_register(CPUOFF + GIE); // LPM0 with interrupts enabled
results[0] = ADC10MEM;

ADC10CTL0 &= ~ENC;

ADC10CTL1 = INCH_11; // AVcc/2
ADC10CTL0 = SREF_1 + ADC10SHT_2 + REFON + ADC10ON + ADC10IE + REF2_5V;
for( degC = 240; degC > 0; degC-- ); // delay to allow reference to
settle
ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
__bis_SR_register(CPUOFF + GIE); // LPM0 with interrupts enabled
results[1] = ADC10MEM;
ADC10CTL0 &= ~ENC;
ADC10CTL0 &= ~(REFON + ADC10ON); // turn off A/D to save power

// oC = ((A10/1024)*1500mV)-986mV)*1/3.55mV = A10*423/1024 - 278
// the temperature is transmitted as an integer where 32.1 = 321
// hence 4230 instead of 423

updateTach();

temp = results[0];
degC = ((temp - 673) * 4230) / 1024;

if( tempOffset != 0xFFFF )
{
degC += tempOffset;
}
/*message format, UB = upper Byte, LB = lower Byte
-------------------------------
|degC LB | degC UB | volt LB |
-------------------------------
0 1 2
*/

temp = results[1];
volt = (temp*25)/512;
rpm = (tachRPM)/100; //added for RPM test

msg[0] = degC&0xFF;
msg[1] = (degC>>8)&0xFF;
msg[2] = volt;
msg[3] = rpm; if (SMPL_SUCCESS == SMPL_Send(linkID1, msg, sizeof(msg)))
{
BSP_TOGGLE_LED2();
}
else
{
BSP_TOGGLE_LED2();
BSP_TOGGLE_LED1();
}
}
}
//Version: ED_rr1.1. addition
void updateTach(void)
{

P2IE &= ~(TACH); // Disable tachometer interrupt
P2.0
_NOP(); // Wait 1 instruction cycle
// Convert pulse count to RPM
tachRPM = ((tachCount)/PULSESPERREVOLUTION)*60;
P2IE |= (TACH); // Re-enable tachometer
interrupt P2.0
tachCount = 0; // Reset the pulse counter
}void refreshTach()
{
//if (tachRPM == 0) // Check if fan(s) stopped
//setStatusLED(ALARM); // Set ALARM LED
//else
//setStatusLED(OK); // Clear ALARM LED
updateTach(); // Refresh tachometer readings
//displayTach(tachRPM); // Display RPM on LCD //if
(tachRPM > lastRPM) // Check if current RPM > last
//displayUpArrow(); // Yes, display UP arrow
//else
//displayDownArrow(); // No, display DOWN arrow
//lastRPM = tachRPM; // Save RPM history for
future
}
/*----------------------------------------------------------
* ADC10 interrupt service routine
----------------------------------------------------------*/
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR(void)
{
__bic_SR_register_on_exit(CPUOFF); // Clear CPUOFF bit from 0(SR)
}/*----------------------------------------------------------
* Timer A0 interrupt service routine
----------------------------------------------------------*/
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
__bic_SR_register_on_exit(LPM3_bits); // Clear LPM3 bit from 0(SR)
} // PORT2 Interrupt Service Routine
#pragma vector=PORT2_VECTOR
__interrupt void isrPORT2(void)
{

if (P2IFG & TACH) { // Tachometer pulse detected
tachCount++; // Increment tach counter
P2IFG &= ~TACH; // Clear interrupt flag//Changed TACH

__bic_SR_register_on_exit(LPM3_bits); // Don't forget to exit the low
power mode.
MRFI_GpioIsr();
}
}
//Version: ED_rr1.1. addition END ThanksRandy

----- Original Message -----
From: "Dan Muzzey"
To: m...@yahoogroups.com
Subject: RE: [msp430] eZ430 data transfer within main code
Date: Fri, 22 Aug 2008 08:31:24 -0500

Randy

Looking through the code I see several things that look a little
strange. Some of them are probably purely style differences. I'm not
sure what the line interrupt P2.0 does. Is it a continuation of the
comment from the line above?

Starting with the interrupt. If you put a breakpoint on this line:

tachCount++; // Increment tach counter

does the program stop?

Additionally, what type of variable is tachCount? I'm assuming it is
a
global. However, we would write this as TachCount. The firmware
standard we abide by calls this out. That being said, it wouldn't
effect the program. However, is tachCount volatile? I'm thinking it
should be since it can change at any time.

If the program doesn't stop there then check the ISR setup, port
setup,
and all that stuff. If it does stop then manually load tachCount with
some value. Does this wash through to the rest of the program?

I also noticed that if tachCount is less than PULSESPERREVOLUTION
then
tachRPM is going to be zero.

One more style comment then I'll shut up about style.

P2IE &= ~(TACH); // Disable tachometer
interrupt P2.0
_NOP(); // Wait 1 instruction cycle
// Convert pulse count to RPM
tachRPM = ((tachCount)/PULSESPERREVOLUTION)*60;
P2IE |= (TACH); // Re-enable tachometer
interrupt P2.0
tachCount = 0; // Reset the pulse counter

Could be written a little clearer and have the interrupts disabled
less
if you did it this way:

P2IE &= ~(TACH); // Disable tachometer
Tachcopy = tachCount;
tachCount = 0;
P2IE |= (TACH); // Re-enable tachometer

At this point proceed with the math. This is a pretty minor change
but
it should make it more predictable in the amount of time the
interrupts
will be disabled.

Dan

________________________________

From: m...@yahoogroups.com
[mailto:m...@yahoogroups.com ] On
Behalf
Of randy ram
Sent: Thursday, August 21, 2008 11:47 PM
To: m...@yahoogroups.com
Subject: [msp430] eZ430 data transfer within main code

I having problem sending the pulse count from Port2 into the main
program.

When the port see a high signal is only sends out 0's instead of
sending the number of count to the main program and then giving out
the right data.

I know for sure that the problem is in the ISR as I tried giving
constant number with the main for the count numbers and it will send
out the right value. And if I put a constant into the Vector 2 isr,
it still says 0.

Here are few snapshoots of the code.

Any help will be greatly appreciated.

Thanks

updateTach();

temp = results[1];
volt = (temp*25)/512;
rpm = (tachRPM)/100; //added for RPM test

msg[0] = degC&0xFF;
msg[1] = (degC>>8)&0xFF;
msg[2] = volt;
msg[3] = rpm;

void updateTach(void)
{

P2IE &= ~(TACH); // Disable tachometer
interrupt P2.0
_NOP(); // Wait 1 instruction cycle
// Convert pulse count to RPM
tachRPM = ((tachCount)/PULSESPERREVOLUTION)*60;
P2IE |= (TACH); // Re-enable tachometer
interrupt P2.0
tachCount = 0; // Reset the pulse counter
}

// PORT2 Interrupt Service Routine
#pragma vector=PORT2_VECTOR
__interrupt void isrPORT2(void)
{

if (P2IFG & TACH) { // Tachometer pulse detected
tachCount++; // Increment tach counter
P2IFG &= ~TACH; // Clear interrupt flag//Changed TACH

__bic_SR_register_on_exit(LPM3_bits); // Don't forget to exit the
low power mode.
MRFI_GpioIsr();
}
}

--
Be Yourself @ mail.com!
Choose From 200+ Email Addresses
Get a Free Account at www.mail.com

[Non-text portions of this message have been removed]

[Non-text portions of this message have been removed]

--
Be Yourself @ mail.com!
Choose From 200+ Email Addresses
Get a Free Account at www.mail.com

[Non-text portions of this message have been removed]

[Non-text portions of this message have been removed]
------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

RE: eZ430 data transfer within main code - randy ram - Aug 22 21:18:40 2008

I just tried changing to volatile unsigned int tachCount. What I did
find out from the debug screen is that, 1. the tachCount keeps increasing
when I pull it high. And when ground it, it stop at where the last number
is. Then when I pull it high, it continues the count.It will not reset to
0. 2. tachRPM =3D (tachCount/PULSESPERREVOLUTION)*60;I can see the
tachCount here and so are the other values. BUT tachRPM is still 0. I do
not know what it is waiting for to complete the calculation. Let me know
if you have any other suggestions. ThanksRandy

----- Original Message -----
From: "Andreas K=F6pke"
To: m...@yahoogroups.com
Subject: RE: [msp430] eZ430 data transfer within main code
Date: Fri, 22 Aug 2008 18:48:51 +0200

Please change the declaration to:
volatile unsigned int tachCount =3D 0; // Count revolutions of fan

AFAIK you are checking the variable in a loop. With some luck the
compiler managed to hold tachCount in one of its registers -- unaware
that it is changed outside the loop by an interrupt.

Be nice to your compiler and tell it that an interrupt changes the
variable.

Best, Andreas

=20=20

--=20
Be Yourself @ mail.com!
Choose From 200+ Email Addresses
Get a Free Account at www.mail.com

[Non-text portions of this message have been removed]
------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

RE: eZ430 data transfer within main code - randy ram - Aug 22 21:30:08 2008

Dan, I took your advice too. I finally found out how to use the debugger
and watch window.I can see the number now. 1. As far as the degC goes, it
is working great. It was the code TI themselves.2. I DO have a problem
with the updateTach. Seems like all the value fill in such as tachCount,
PULSE... but tachRPM still stays at 0. And tachCount does not seem to
clear to 0 before of this. I think. So, tachCount keeps increasing.Maybe
I should put a actual delay of say 3 seconds, so it will keep counting
the number of pulses then go do the math, then clear the count. Now, i
need to figure out how and where I place the delay/timer for this. Let me
know if you have any other suggestions. ThanksRandy void updateTach(void)
{

P2IE &= ~(TACH); // Disable tachometer interrupt
P2.0
_NOP(); // Wait 1 instruction cycle
// Convert pulse count to RPM
tachRPM = (tachCount/PULSESPERREVOLUTION)*60;
P2IE |= (TACH); // Re-enable tachometer
interrupt P2.0
tachCount = 0; // Reset the pulse counter
}

----- Original Message -----
From: "Dan Muzzey"
To: m...@yahoogroups.com
Subject: RE: [msp430] eZ430 data transfer within main code
Date: Fri, 22 Aug 2008 11:54:51 -0500

Couple items.

Drop a break point in the ISR. See if its getting triggered. It
should
be triggered every time the input changes state. Then single step it
out. Bring up the variable in the watch window. Keep an eye on whats
doing it. I'm not sure your delay loops will work either. The
compiler
may edit them out since they do not do anything obvious. Maybe
someone
with a little more C insite can help. I think this line: for( degC =
240; degC > 0; degC-- ); // delay to allow reference to settle will
be
optimized out. Declare decC as volatile. There are much better ways
to
do delays as well. I didn't see any real time delays in the program.
It looks like its going to drop into the while loop in LinkTo(). If
this is so, UpdateTach is going to run pretty often. UpdateTach will
clear out the count every time. As someone else directed, tachCount
should be volatile. I think this will fix that problem but may
uncover
a couple others.

Dan

________________________________

From: m...@yahoogroups.com [mailto:m...@yahoogroups.com] On
Behalf
Of randy ram
Sent: Friday, August 22, 2008 9:33 AM
To: m...@yahoogroups.com
Subject: RE: [msp430] eZ430 data transfer within main code

All Port2.0 needs to do is take then umber of pulses (rising edge)
that
arrive from a sensor within a certain time. Then I am converting it
into
RPM. When I actually to place a constant(tachCount) outside of the
Port2
Interupt Script, the RPM does show up at the receiving end with no
problem. And when I place the same constant into the Port2 Interupt
Script, I get 0000.And yes, if number is less then
PULSEPERREVOLUTION,
then number will be 0. Which I am okay with. Here is the know code. I
know it is a little long but if you could just take a look at the
just
the TACH sections , it would be great.
#include "bsp.h"
#include "mrfi.h"
#include "mrfi_defs.h"
#include "nwk_types.h"
#include "nwk_api.h"
#include "bsp_leds.h"
#include "bsp_buttons.h"
#include "vlo_rand.h"
#include "msp430x22x4.h"void linkTo(void);
void MCU_Init(void);
void updateTach(void);__no_init volatile int tempOffset @ 0x10F4; //
Temperature offset set at production
__no_init volatile char Flash_Addr[4] @ 0x10F0; // Flash address set
randomlyvoid createRandomAddress(); //Version: ED_rr1.1. addition
// Port2 Pin Configuration
int PULSESPERREVOLUTION = 1; // Frequency of sample point
in a rev
unsigned int tachCount = 0; // Count revolutions of fan
unsigned int tachRPM = 0; // Stores RPM of fan
unsigned int lastRPM = 0; // Stores RPM of last reading
//Version: ED_rr1.1. addition ended

void main (void)
{
addr_t lAddr;
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
{
// delay loop to ensure proper startup before SimpliciTI increases
DCO
// This is typically tailored to the power supply used, and in
this case
// is overkill for safety due to wide distribution.
volatile int i;
for(i = 0; i < 0xFFFF; i++)

{}
}
if( CALBC1_8MHZ == 0xFF ) // Do not run if cal values are
erased
{
volatile int i;
P1DIR |= 0x03;
BSP_TURN_ON_LED1();
BSP_TURN_OFF_LED2();
while(1)
{
for(i = 0; i < 0x5FFF; i++){}
BSP_TOGGLE_LED2();
BSP_TOGGLE_LED1();
}
}

// SimpliciTI will change port pin settings as well
// SimpliciTI will change port pin settings as well
P1DIR = 0xFF;
P1OUT = 0x00;
//P2DIR = 0x26; // 100110 where Port2.0 is input. Is this right?
P2OUT = 0x00; // no output selected. Is this right?
//P2IE |= 0x01; // P2.0 interrupt enabled
//P2IES |= 0x01; // P2.0 Hi/lo edge
//P2IFG &= ~0x01; // P2.0 IFG cleared
P3DIR = 0xC0;
P3OUT = 0x00;
P4DIR = 0xFF;
P4OUT = 0x00;
P2DIR &= ~0x07; // P2.0-P2.2 as input
P2IE |= 0x07; // P2.0-p2.2 interrupt enabled
P2IES &= ~0x07; // P2.0-p2.2 lo/Hi edge
P2IFG &= ~0x07; // P2.0-P2.2 IFG cleared

if( Flash_Addr[0] == 0xFF &&
Flash_Addr[1] == 0xFF &&
Flash_Addr[2] == 0xFF &&
Flash_Addr[3] == 0xFF )
{
createRandomAddress(); // set Random device address at
initial startup
}
lAddr.addr[0]=Flash_Addr[0];
lAddr.addr[1]=Flash_Addr[1];
lAddr.addr[2]=Flash_Addr[2];
lAddr.addr[3]=Flash_Addr[3];
SMPL_Ioctl(IOCTL_OBJ_ADDR, IOCTL_ACT_SET, &lAddr);
BCSCTL1 = CALBC1_8MHZ; // Set DCO after random
function
DCOCTL = CALDCO_8MHZ;

BCSCTL3 |= LFXT1S_2; // LFXT1 = VLO
TACCTL0 = CCIE; // TACCR0 interrupt enabled
TACCR0 = 12000; // ~ 1 sec
TACTL = TASSEL_1 + MC_1; // ACLK, upmode

// keep trying to join until successful. toggle LEDS to indicate that
// joining has not occurred. LED3 is red but labeled LED 4 on the EXP
// board silkscreen. LED1 is green.
while (SMPL_NO_JOIN == SMPL_Init((uint8_t (*)(linkID_t))0))
{
BSP_TOGGLE_LED1();
BSP_TOGGLE_LED2();;
__bis_SR_register(LPM3_bits + GIE); // LPM3 with interrupts enabled
}
// unconditional link to AP which is listening due to successful
join.
linkTo();}void createRandomAddress()
{
unsigned int rand, rand2;
do
{
rand = TI_getRandomIntegerFromVLO(); // first byte can not be 0x00 of
0xFF
}
while( (rand & 0xFF00)==0xFF00 || (rand & 0xFF00)==0x0000 );
rand2 = TI_getRandomIntegerFromVLO();

BCSCTL1 = CALBC1_1MHZ; // Set DCO to 1MHz
DCOCTL = CALDCO_1MHZ;
FCTL2 = FWKEY + FSSEL0 + FN1; // MCLK/3 for Flash Timing
Generator
FCTL3 = FWKEY + LOCKA; // Clear LOCK & LOCKA bits
FCTL1 = FWKEY + WRT; // Set WRT bit for write
operation Flash_Addr[0]=(rand>>8) & 0xFF;
Flash_Addr[1]=rand & 0xFF;
Flash_Addr[2]=(rand2>>8) & 0xFF;
Flash_Addr[3]=rand2 & 0xFF;

FCTL1 = FWKEY; // Clear WRT bit
FCTL3 = FWKEY + LOCKA + LOCK; // Set LOCK & LOCKA bit
}void linkTo()
{

linkID_t linkID1;
uint8_t msg[4];//changed from 3 to 4 060108RR // keep trying to
link...
while (SMPL_SUCCESS != SMPL_Link(&linkID1))
{
__bis_SR_register(LPM3_bits + GIE); // LPM3 with interrupts enabled
BSP_TOGGLE_LED1();
BSP_TOGGLE_LED2();
}

// Turn off all LEDs
if (BSP_LED1_IS_ON())
{
BSP_TOGGLE_LED1();
}
if (BSP_LED2_IS_ON())
{
BSP_TOGGLE_LED2();
}
while (1)
{
volatile long temp;
int degC, volt, rpm;
int results[3];
SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_SLEEP, "" );
__bis_SR_register(LPM3_bits+GIE); // LPM3 with interrupts enabled
SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_AWAKE, "" );

BSP_TOGGLE_LED2();
ADC10CTL1 = INCH_10 + ADC10DIV_4; // Temp Sensor ADC10CLK/5
ADC10CTL0 = SREF_1 + ADC10SHT_3 + REFON + ADC10ON + ADC10IE +
ADC10SR;
for( degC = 240; degC > 0; degC-- ); // delay to allow reference to
settle
ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
__bis_SR_register(CPUOFF + GIE); // LPM0 with interrupts enabled
results[0] = ADC10MEM;

ADC10CTL0 &= ~ENC;

ADC10CTL1 = INCH_11; // AVcc/2
ADC10CTL0 = SREF_1 + ADC10SHT_2 + REFON + ADC10ON + ADC10IE +
REF2_5V;
for( degC = 240; degC > 0; degC-- ); // delay to allow reference to
settle
ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
__bis_SR_register(CPUOFF + GIE); // LPM0 with interrupts enabled
results[1] = ADC10MEM;
ADC10CTL0 &= ~ENC;
ADC10CTL0 &= ~(REFON + ADC10ON); // turn off A/D to save power

// oC = ((A10/1024)*1500mV)-986mV)*1/3.55mV = A10*423/1024 - 278
// the temperature is transmitted as an integer where 32.1 = 321
// hence 4230 instead of 423

updateTach();

temp = results[0];
degC = ((temp - 673) * 4230) / 1024;

if( tempOffset != 0xFFFF )
{
degC += tempOffset;
}
/*message format, UB = upper Byte, LB = lower Byte
-------------------------------
|degC LB | degC UB | volt LB |
-------------------------------
0 1 2
*/

temp = results[1];
volt = (temp*25)/512;
rpm = (tachRPM)/100; //added for RPM test

msg[0] = degC&0xFF;
msg[1] = (degC>>8)&0xFF;
msg[2] = volt;
msg[3] = rpm; if (SMPL_SUCCESS == SMPL_Send(linkID1, msg,
sizeof(msg)))
{
BSP_TOGGLE_LED2();
}
else
{
BSP_TOGGLE_LED2();
BSP_TOGGLE_LED1();
}
}
}
//Version: ED_rr1.1. addition
void updateTach(void)
{

P2IE &= ~(TACH); // Disable tachometer interrupt
P2.0
_NOP(); // Wait 1 instruction cycle
// Convert pulse count to RPM
tachRPM = ((tachCount)/PULSESPERREVOLUTION)*60;
P2IE |= (TACH); // Re-enable tachometer
interrupt P2.0
tachCount = 0; // Reset the pulse counter
}void refreshTach()
{
//if (tachRPM == 0) // Check if fan(s) stopped
//setStatusLED(ALARM); // Set ALARM LED
//else
//setStatusLED(OK); // Clear ALARM LED
updateTach(); // Refresh tachometer readings
//displayTach(tachRPM); // Display RPM on LCD //if
(tachRPM > lastRPM) // Check if current RPM > last
//displayUpArrow(); // Yes, display UP arrow
//else
//displayDownArrow(); // No, display DOWN arrow
//lastRPM = tachRPM; // Save RPM history for
future
}
/*----------------------------------------------------------
* ADC10 interrupt service routine
----------------------------------------------------------*/
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR(void)
{
__bic_SR_register_on_exit(CPUOFF); // Clear CPUOFF bit from 0(SR)
}/*----------------------------------------------------------
* Timer A0 interrupt service routine
----------------------------------------------------------*/
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
__bic_SR_register_on_exit(LPM3_bits); // Clear LPM3 bit from 0(SR)
} // PORT2 Interrupt Service Routine
#pragma vector=PORT2_VECTOR
__interrupt void isrPORT2(void)
{

if (P2IFG & TACH) { // Tachometer pulse detected
tachCount++; // Increment tach counter
P2IFG &= ~TACH; // Clear interrupt flag//Changed TACH

__bic_SR_register_on_exit(LPM3_bits); // Don't forget to exit the low
power mode.
MRFI_GpioIsr();
}
}
//Version: ED_rr1.1. addition END ThanksRandy

----- Original Message -----
From: "Dan Muzzey"
To: m...@yahoogroups.com
Subject: RE: [msp430] eZ430 data transfer within main code
Date: Fri, 22 Aug 2008 08:31:24 -0500

Randy

Looking through the code I see several things that look a little
strange. Some of them are probably purely style differences. I'm not
sure what the line interrupt P2.0 does. Is it a continuation of the
comment from the line above?

Starting with the interrupt. If you put a breakpoint on this line:

tachCount++; // Increment tach counter

does the program stop?

Additionally, what type of variable is tachCount? I'm assuming it is
a
global. However, we would write this as TachCount. The firmware
standard we abide by calls this out. That being said, it wouldn't
effect the program. However, is tachCount volatile? I'm thinking it
should be since it can change at any time.

If the program doesn't stop there then check the ISR setup, port
setup,
and all that stuff. If it does stop then manually load tachCount with
some value. Does this wash through to the rest of the program?

I also noticed that if tachCount is less than PULSESPERREVOLUTION
then
tachRPM is going to be zero.

One more style comment then I'll shut up about style.

P2IE &= ~(TACH); // Disable tachometer
interrupt P2.0
_NOP(); // Wait 1 instruction cycle
// Convert pulse count to RPM
tachRPM = ((tachCount)/PULSESPERREVOLUTION)*60;
P2IE |= (TACH); // Re-enable tachometer
interrupt P2.0
tachCount = 0; // Reset the pulse counter

Could be written a little clearer and have the interrupts disabled
less
if you did it this way:

P2IE &= ~(TACH); // Disable tachometer
Tachcopy = tachCount;
tachCount = 0;
P2IE |= (TACH); // Re-enable tachometer

At this point proceed with the math. This is a pretty minor change
but
it should make it more predictable in the amount of time the
interrupts
will be disabled.

Dan

________________________________

From: m...@yahoogroups.com
[mailto:m...@yahoogroups.com ] On
Behalf
Of randy ram
Sent: Thursday, August 21, 2008 11:47 PM
To: m...@yahoogroups.com
Subject: [msp430] eZ430 data transfer within main code

I having problem sending the pulse count from Port2 into the main
program.

When the port see a high signal is only sends out 0's instead of
sending the number of count to the main program and then giving out
the right data.

I know for sure that the problem is in the ISR as I tried giving
constant number with the main for the count numbers and it will send
out the right value. And if I put a constant into the Vector 2 isr,
it still says 0.

Here are few snapshoots of the code.

Any help will be greatly appreciated.

Thanks

updateTach();

temp = results[1];
volt = (temp*25)/512;
rpm = (tachRPM)/100; //added for RPM test

msg[0] = degC&0xFF;
msg[1] = (degC>>8)&0xFF;
msg[2] = volt;
msg[3] = rpm;

void updateTach(void)
{

P2IE &= ~(TACH); // Disable tachometer
interrupt P2.0
_NOP(); // Wait 1 instruction cycle
// Convert pulse count to RPM
tachRPM = ((tachCount)/PULSESPERREVOLUTION)*60;
P2IE |= (TACH); // Re-enable tachometer
interrupt P2.0
tachCount = 0; // Reset the pulse counter
}

// PORT2 Interrupt Service Routine
#pragma vector=PORT2_VECTOR
__interrupt void isrPORT2(void)
{

if (P2IFG & TACH) { // Tachometer pulse detected
tachCount++; // Increment tach counter
P2IFG &= ~TACH; // Clear interrupt flag//Changed TACH

__bic_SR_register_on_exit(LPM3_bits); // Don't forget to exit the
low power mode.
MRFI_GpioIsr();
}
}

--
Be Yourself @ mail.com!
Choose From 200+ Email Addresses
Get a Free Account at www.mail.com

[Non-text portions of this message have been removed]

[Non-text portions of this message have been removed]

--
Be Yourself @ mail.com!
Choose From 200+ Email Addresses
Get a Free Account at www.mail.com

[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]

--
Be Yourself @ mail.com!
Choose From 200+ Email Addresses
Get a Free Account at www.mail.com

[Non-text portions of this message have been removed]
------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: eZ430 data transfer within main code - Dan Bloomquist - Aug 22 22:32:52 2008

randy ram wrote:
> tachRPM = (tachCount/PULSESPERREVOLUTION)*60;

Hi Randy,
This may be nothing, but this looks suspicious.

if tachCount < PULSESPERREVOLUTION you will have 0 * 60. More properly
is to multiply first.

tachRPM= tacC * 60 / PPREV;
If you are concerned about overflow in the mult, write a reusable 32 bit
'MultDiv'.

Best, Dan.
--
email: y...@lakeweb.com but drop the 'x'.
------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )