Quantcast
Channel: MSP430 Technical Forums
Viewing all articles
Browse latest Browse all 2077

reduce startup time on MSP430FR5739

$
0
0
Hi
I have a real short program which runs on a MSP430FR5739. I have just a short impuls of energy to start the MC and write to the FRAM. The problem is that the amount of energy is nearly enough. At the actual programm, the MC needs 98% to start and 2% to execute the program.
 
So is there any posibility to reduce the startupt time? My Programm is not time critical or something...
 
Thanks for your help
 
Manuel
 
PS: Is my first MSP430 Project...
 
 
#include <msp430.h>
 
#pragma SET_DATA_SECTION(".fram_vars")
long umdrehung;
//Positionszustände
char pos;
char prepos;
char preprepos;
#pragma SET_DATA_SECTION()
 
 
volatile unsigned int i;
volatile unsigned int j;
volatile unsigned long temp = 0;
 
int main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
 
////////////// Clockspeed auf 8Mhz
 CSCTL0_H = 0xA5;
 CSCTL1 |= DCOFSEL0 + DCOFSEL1;             // Set max. DCO setting
 CSCTL2 = SELA_3 + SELS_3 + SELM_3;        // set ACLK = MCLK = DCO
 CSCTL3 = DIVA_0 + DIVS_0 + DIVM_0;        // set all dividers
 
 // _delay_cycles(1); = 0.125us
 
////////////// Ausgänge / Eingänge definieren
 //P2OUT = 0;                                // output ACLK
 
//////////////  P3DIR |= 0x70;  // Pin 4, 5, 6 Als ausgang definieren
 P2DIR |= 0x07;  // Pin 2.0, 2.1, 2.2 Als ausgang definieren
 P1DIR |= 0x08;  // Pin 3.0 Als ausgang
 P1DIR &= 0x07 + ~BIT1 + ~BIT2 + ~BIT4; // P1.0 1.1 1.2  als eingang def
 P1DIR &= ~BIT4; // P1.0 1.1 1.2  als eingang def
 P4DIR &= ~BIT0; // P4.0 Als Reset eingang
 
// Slaveselect P2.2 auf 1 setzen
 P2OUT |= BIT2;
 
while(1){
 
 
P1OUT |= BIT3;  // IR Dioden aktivieren
 
_delay_cycles(80); //10us wait
 
pos = P1IN;  //Zustände in pos schreiben
 
 P1OUT &= ~BIT3;  // IR Dioden deaktivieren
 
 
 
// Auswertung
  if(P1IN & BIT4){
  if(!(pos==prepos) && (!((pos&0x07)==0)))//eine veränderung hat stattgefunden
  {
  if(pos&BIT1)//mitte ist aktiv
  {
 
  if(prepos&BIT0 && preprepos&BIT2)umdrehung++;
  if(prepos&BIT2 && preprepos&BIT0)umdrehung--;
 
  }
 
  preprepos=prepos;
  prepos=pos;
  }
  }
 
 
 
 
///////////////////////////////////////////////// Send
temp = umdrehung;
 
P2OUT &= ~BIT2; // Slave Aktivieren
 
for(j=4; j>0; j--){
for(i=8; i>0; i--){
 
if(temp&0x80000000) P2OUT |= BIT1;
else P2OUT &= ~BIT1;
 
temp=temp<<1;
 
_delay_cycles(5);
P2OUT |= BIT0;  // CLK Setzen
_delay_cycles(1);
P2OUT &= ~BIT0; // CLK zurücksetzen
 
}
_delay_cycles(50); // Pause zwischen den 8Bit  Blöcken
}
 
P2OUT |= BIT2; // Slave deaktivieren
//_delay_cycles(800); // 100us delay
 
 
 
}
}

Viewing all articles
Browse latest Browse all 2077

Trending Articles