Jump to content
43oh

omerdf

Members
  • Content Count

    20
  • Joined

  • Last visited

Posts posted by omerdf

  1. Hello ,

    I'm using MSP430F5131 Microcontroller of TI.
    I also use a MSP-FET Emulator in order to program that device.
    i have written a code in Code Composer Studio (Defined the properties of CCS's project to the devices im using).
    I compiled the program and no errors has found.
    Then i connected the MSP-FET to the board according to the datasheet SLA138H , page 26 . (The board supplies the 3.3V so i connected it to pin 4 in the JTAG connector of the MSP-FET). I didn't connect the TEST/VPP and didnt connect the the resistor R2 330Ohms as instructed in that datasheet coz i dont need to use the fuse blow protection functionality.

    My problem occurs when i try to download the program to the MSP430 device , when i hit on the downloading button an error message pops up :
    "Error connecting to the target: Unknown device".

    I tried to do the same in IAR Embedded Workbench (Same code , same properties) it asks me to update my firmware of the MSP-FET i click ok and it updates the firmware , but then i get the same error as i have got in the Code Composer Studio : 
    "Tue May 01, 2018 11:08:46: Fatal error: Could not find device (or device not supported) Session aborted! "

    It is needed to be said that when i hit on the download button the "MODE" red led on the MSP-FET flashes and then stays on after the error message has been popped.

    I tried to get the 3.3V supply voltage for the downloading purposes from the MSP-FET (JTAG pin 2) and it still doesn't work and get the same error.

    I also made sure that the MSP430 gets the amount of voltage its needed (3.3V from the board by a regulator).

    I would like to know how i can solve this problem and download my code into the MSP430.

    I have attached a wiring schematic of the board. hope it will help.

    thanks in advance.

    updated electrical drawing.pdf

  2. In the msp430 family datasheet they mention a unused pins , they say that if AVcc and AVss are not in use they should be connected to DVcc and DVss  - i think they get their supply from the digital pins.

     

    I found another problem though , i use a regulator of 3.3V which supplies my msp430 , although i noticed that this regulator supplies only 0.7V and i know that the MSP430 got to have at least 1.8V - so maybe thats the problem.

  3. 1) I have connected :

     

    - RST/NMI/SBWTDIO of the MCU to TDO/TDI pin 1 of the MSP-FET.

    - TEST/SBWTCK of the MCU to TCK pin 7 of the MSP-FET.

    - a 3.3V that is supplied from a regulator in the PCB to VCC_TOOL pin 2 of the MSP-FET.

    - GND of the PCB to GND pin 9 of the MSP-FET.

     

    2) In the IAR - Options - FET Debugger , i have unchecked the Target VCC.

        so you say that AVcc and AVss must be connected even if i dont use any analog options at all? it just allows the MSP-FET to download the program?

     

    3)  Yes i have specified the exact MSP430 5131.

     

    4)  Yes i have designed the board according to the MSP430F5131 data sheet . 

     

    I have attached the whole PCB electrical wiring to this post and the FET Debugger options i used in the IAR. and the error window .

    notice that AVcc and AVss are not attached at all , i know it's the second PCB with MSP43-F5131 they are using and it was never needed to connect the AVcc and AVss.

     

    It's important to say that even if i dont connect the MSP-FET to the MCU at all it still pops the same error.

    PCB electrical wiring.pdf

    post-49756-0-38504200-1485098769_thumb.png

    post-49756-0-36326000-1485098997_thumb.png

  4.  Hello,

     

    I'm using MSP430F5131 and trying to program it by IAR Embedded Workbench while using the MSP-FET debugger.

     

    A short background of the PCB:

    After i compiled the code in IAR with not errors found , i connected the MSP-FET to the MSP430 in a Spi-Bi-Wire connection according to the datasheet.

    The MSP430 is placed in a PCB which includes 12V input voltage and 2 regulators of 5V and 3.3V . The MSP430 I/O's are connected according to the datasheet (including external pullup resistors and capacitors) along with the Spi-Bi-Wire connections.

    I energized the PCB with a 12V supply voltage , connected the MSP-FET's connector to a Header connector on the PCB and the other side connected to the PC by USB.

     

    My problem is :

    In the IAR , once i try to download the code into the MSP430 (by clicking the 'Download and Debug' button) it says that it needs a firmware update , so i clicked ok and download the new update , but when it tries to initialize hardware i encounter the error :

     

    "Fatal error: Could not find device (or device not supported)

     

    Session aborted!"

     

    I have tried multiple things in order to find the solution - with no success .

     

    Does the AVcc and AVss needs to be connected even if i dont use any analog options? coz its not connected to anything.

     

    I also tried to download the program to the MSP430 with code composer studio but encounter the same error.

     

    Thanks in advance.

     

  5. Hello ,


    I am using MSP430F5131, IAR Workbench compiler and i have purchased MSP-FET.


    i have successfully compiled my code in IAR Workbench , although when i try to download the program through the MSP-FET using the IAR Workbench (i have clicked on download and debbug and it has started to initialize the device)  i encountered this error :


     


    Fatal error: Could not find device (or device not supported)


    Session aborted!


    Thanks in advance


  6. Before i program my MSP430 by MSP-FET. Could you take a look at my code again (after it has been compiled successfully) , according to the requirements i have mentioned above:

    #include "msp430.h"
    #include "intrinsics.h"
    
    // defining flags as volatile(coz we use these variables in the main and in the ISR as well):
    volatile unsigned int timerCount = 0; 	//defines the millisecond counter
    volatile unsigned int normalPulse1=0; 	//defines another flag to indicates when 1 second has passed for normal pulse1
    volatile unsigned int badPulse1=0;		//defines another flag to indicates when 1 second has passed for bad pulse1
    volatile unsigned int normalPulse2=0; 	//defines another flag to indicates when 1 second has passed for normal pulse2
    volatile unsigned int badPulse2=0;		//defines another flag to indicates when 1 second has passed for bad pulse2
    volatile unsigned int secondsCount=0;	//defines the seconds count for the bad pulse
    
    
    void main() { //Main function
    
    	// configure watchdog timer:
    	WDTCTL = WDTPW | WDTHOLD;					// Stop watchdog timer
    	P2OUT &= ~(BIT4); 							//preload 1pps to '0'
    
    
    	// set I/O pins directions:
    	P1DIR |=BIT6+BIT7;                      //set p1.x to 11000000
    	P2DIR |=BIT4;	                       // Set P2.4 to output direction
        PJDIR |=BIT0+BIT1+BIT3;                // set pj.x output 0000 1011
        P2SEL |= BIT4;						   //select the option of using TD0.0 in pin 2.4
        //P2IES |= BIT4;                         // high -> low is selected with IES.x = 1.
        //P2IFG &= ~(BIT4);                      // To prevent an immediate interrupt, clear the flag for
                                              // P2.4 before enabling the interrupt.
        //P2IE |= BIT4;                          // Enable interrupts for P2.4
    
        // Configure XT1 (external oscillator):
        PJSEL |= BIT4+BIT5;						// port select for xt1
        UCSCTL6 &= ~(XT1OFF); 				    //xt1 is on
        UCSCTL3 = 0;                            // FLL REFERENCE CLOCK REFERENCE = XT1
    
        // configure TD0.0 (TimerD0.0):
        TD0CTL0 |=MC_1+ID_3+TDSSEL_0+TDIE+CNTL_0+TDCLR;                //defining timer d TD0.0 (P2.4) upmode , devide by 8 , TDCLK , enable interupt , 
        TD0CCR0=1600-1;                          // setting TAR count up value 1600 (12.8MHz / 8 = 1.6MHz , 1.6MHz / 1600 = 1000 Hz) when 1000 is passed means 1 second has passed as well
    
        TD0CCTL0 |= CCIE;                        //ENABLES CCIFG INTERUPT ON CCR0
    	
    
        __enable_interrupt();    					//enables interupts in the ISR
    
    
        for(;{                      // Main loop - Endless loop
    
    
    
        	//   EXTERNAL / INTERNAL SELECTION BY SW4
    
        	if ((P2IN & BIT2)==0){         //  INTERNAL MODE
    		
        		PJOUT |=BIT3;              // sends '1' from pj.3 output to the multiplexer U4 (uses the internal 1pps)
    
        		//PULSE 1 : DESCRETE ON/OFF AND SWITCH ON/BAD/OFF
    
                         if ((P2IN & BIT0)==0 || (P1IN & BIT0)==0) {        //NORMAL SIGNAL OF 1PPS checks if descrete source is on or 1pps sw pulse 1 is on
                        	 P1OUT |= BIT6; 									//ENABLES PULSE BY THE 'AND' GATE
                        	 PJOUT |= BIT0;									//ENABLES TTL TO RS232 CONVERTER (FOR DIFF OUTPUT)
                              if(normalPulse1==1){                       //checks if normalPulse1 is on from the ISR
    						    normalPulse1 =0;                           // sets normalPulse1 to 0 again so the ISR will generate the pulse 
    						    P2OUT ^=BIT4;                            //generates 1pps out of p2.4
    						 }
    
                    	 }
                       
                         else {
                        	 P1OUT |= ~(BIT6); 								//DISABLES PULSE BY SENDING A '0' TO THE AND GATE
                         }
    
                         if ((P1IN & BIT2)==0)  {							//PULSE 1 BAD SIGNAL checks if the 1pps sw bad pulse is on
                        	  P1OUT |= BIT6; 									//ENABLES PULSE BY THE 'AND' GATE
                        	  PJOUT |= BIT0;									//ENABLES TTL TO RS232 CONVERTER (FOR DIFF OUTPUT)
    						    if(badPulse1==1){                             //checks if badPulse1 is on from the ISR
    							  badPulse1=0;                                // sets badPulse1 to 0 again so the ISR will generate the pulse
    							  P2OUT ^=BIT4;                            //generates 1pps out of p2.4
    							
    							}
                         }
    
                         //PULSE 2 : DESCRETE ON/OFF AND SWITCH ON/BAD/OFF
    
    
                         if ((P2IN & BIT1)==0 || (P1IN & BIT0)==0){			//NORMAL SIGNAL OF 1PPS checks if descrete source is on or 1pps sw pulse 2 is on
                        	 P1OUT |= BIT7; 									//ENABLES PULSE BY THE 'AND' GATE
                        	 PJOUT |= BIT1;	 								//ENABLES TTL TO RS232 CONVERTER (FOR DIFF OUTPUT)
    							if(normalPulse2==1){
    								normalPulse2=0;								// sets normalPulse2 to 0 again so the ISR will generate the pulse
    								P2OUT ^=BIT4;                            //generates 1pps out of p2.4
    							
    							}
    
    
                         }
    
    
        	
                         else {
                        	 P1OUT |= ~(BIT7);									//DISABLES PULSE BY SENDING A '0' TO THE AND GATE
                         }
    
                         if ((P1IN & BIT3)==0){								//PULSE 2 BAD SIGNAL 
                        	  P1OUT |= BIT6; 									//ENABLES PULSE BY THE 'AND' GATE
                        	  PJOUT |= BIT0;									//ENABLES TTL TO RS232 CONVERTER (FOR DIFF OUTPUT)
    							if(badPulse2==1){
    								badPulse2=0;								// sets badPulse2 to 0 again so the ISR will generate the pulse
    								P2OUT ^=BIT4;                            //generates 1pps out of p2.4
    							}
                         }
    
    
                         }
    
        	else {																//EXTERNAL MODE
        		PJOUT |= ~(BIT3);            //sends '0' from pj.3 output to the multiplexer U4 (uses the external 1pps)
        		P1OUT |= BIT6;      			// ENABLES PULSE 1
        		P1OUT |= BIT7;				//ENABLES PULSE 2
        		PJOUT |= BIT0;				//ENABLES RS422 DIFF OUTPUT	FOR PULSE 1
        		PJOUT |= BIT1;				// ENABLES RS422 DIFF OUTPUT FOR PULSE 2
        	    	}
        	}
    		
    }
    
    	
    	
                        //ISR FOR TIMERD0.0 - NORMAL/BAD PULSE 1 AND 2
    					
    					
    					
    					#pragma vector = TIMER0_D0_VECTOR 				//GENERATES 1PPS EVERY 1s for normal pulse
                       __interrupt void TIMER0_D0 (void){
    					   
    					   //NORMAL PULSE 1 AND 2:
    					   
                    	   if (++timerCount > 500) {   						// checks if the incrementation of timerCount reaches 500 (means 1 second has passed)toggling means doubling the time this is why we need to devide the time to a half. (1000/2=500)
    					                      timerCount = 0;             // resets the millisecond counter to 0
    							       normalPulse1 = 1;             //once it reaches 500 (1 second) normalPulse1 will be 1 
    							       normalPulse2 = 1;				//once it reaches 500 (1 second) normalPulse2 will be 1 
    								 secondsCount++;
                    	                  	   }
                    	                  	  
                         
    					// BAD PULSE 1 AND 2:
    					
    				
                    	   if (secondsCount == 2) {   						// checks if the incrementation of secondCount reaches 2 seconds for bad pulse (means 2 second has passed)
    									secondsCount = 0;             // resets the millisecond counter to 0
    									badPulse1=1;					// once it reaches 2000( 2 seconds) the badPulse1 will be 1.
    									badPulse2=1;					// once it reaches 2000( 2 seconds) the badPulse2 will be 1.
                    	                  	   }
                    	                  	   
    }
    

    Do you have any idea what does it mean 'functionality disable' in the PCB electrical wiring that attached to this post?

    thanks.

    PCB electrical wiring.pdf

  7. Why can't i just do this? :

     

    (this is the error i get after compiling the code in IAR embedded workbench:

     

    Error[Pe101]: "CBCTL0_L" has already been declared in the current scope (at line 136 of "C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.4\430\inc\io430f5131.h") C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.4\430\inc\msp430f5131.h 205 )

     
    
    
    
    #pragma vector = TIMER0_D0_VECTOR 				//GENERATES 1PPS EVERY 1s for normal pulse
      __interrupt void TIMER0_D0 (void){
    					   
    					   //NORMAL PULSE 1 AND 2:
    					   
                    	   if (++timerCount > 500) {   	// checks if the incrementation of timerCount reaches 500 (means 1 second has passed)toggling means doubling the time this is why we need to devide the time to a half. (1000/2=500)
    				timerCount = 0;             // resets the millisecond counter to 0
                                  normalPulse1 = 1;             //once it reaches 500 (1 second) normalPulse1 will be 1 
                                 normalPulse2 = 1;	         //once it reaches 500 (1 second) normalPulse2 will be 1 
    	                       secondsCount++;
                    	                  	   }
                    	                  	  
                         
    					// BAD PULSE 1 AND 2:
    					
    				
                    	   if (secondCount == 2) {   			// checks if the incrementation of secondCount reaches 2 seconds for bad pulse (means 2 second has passed)
    					secondsCount = 0;             // resets the millisecond counter to 0
    					badPulse1=1;			// once it reaches 2000( 2 seconds) the badPulse1 will be 1.
    					badPulse2=1;			// once it reaches 2000( 2 seconds) the badPulse2 will be 1.
                    	                  	   }
                    	                  	   
    }
    
  8. thanks .

     

    ok ill explain a little :

     

    The system includes a toggle switch that can switch between 3 modes : ON / BAD / OFF of pulse : 

    1) when the toggle switch is in ON mode the micro controller will generate a normal 1 pulse per second 1(1Hz) with a duty cycle of             250ms through P2.4 .

    2) when the toggle switch is in BAD mode the micro controller will generate a bad pulse which means (0.5Hz) 1 pulse per 2 seconds with a duty cycle of 250ms through P2.4.

    3) OFF supposed to shut down the pulse

     

    I want both pulses to be accurate while using the external clock of 12.8MHz. therefore i would like to know the best way to write the code for these two kind of pulses (using the ISR or another thing).

  9. ok thanks , 

    P2.4 is my 1pps ( or 2 second signal) output , so i enabled an interupt on this output.

    i know that toggling an output means that you double the time . like if i want a 1 pps and i toggle P2.4 output that means i get 2 seconds pulse per second. thats why i need to count half of the time ( 1000/2 = 500). am i right?

    I heard that i cant use interupts on TD0.0 output in my kind of MSP430. is that true? 

    I also need to implement the duty cycle that is matched to 1pps ( i think its 250ms) , how do i implement it as well?

     

    This is the code : 

    #include <msp430.h>
    #include <intrinsics.h>
    
    
    
    
    volatile unsigned int timerCount = 0; //defines the millisecond counter
    volatile unsigned int normalPulse1=0; //defines another flag to indicates when 1 second has passed for normal pulse1
    volatile unsigned int badPulse1=0;//defines another flag to indicates when 1 second has passed for bad pulse1
    volatile unsigned int normalPulse2=0; //defines another flag to indicates when 1 second has passed for normal pulse2
    volatile unsigned int badPulse2=0;//defines another flag to indicates when 1 second has passed for bad pulse2
    volatile unsigned int secondsCount=0;//defines the seconds count for the bad pulse
    
    int main(void) {
    
    // Main function including some conditions to generate pulse 1 and pulse 2 through P2.4
    
    }
    
     //ISR FOR TIMERD0.0 - NORMAL/BAD PULSE 1 AND 2
    					
    					//NORMAL PULSE 1 AND 2:
    					
    					#pragma vector = TIMER0_D0_VECTOR 				//GENERATES 1PPS EVERY 1s for normal pulse
                       __interrupt void TIMER0_D0 (void){
                    	   if (++timerCount > 500) {   						// checks if the incrementation of timerCount reaches 500 (means 1 second has passed)
    					                       timerCount = 0;             // resets the millisecond counter to 0
    										   normalPulse1 = 1;             //once it reaches 500 (1 second) normalPulse1 will be 1 
    										   normalPulse2 = 1;				//once it reaches 500 (1 second) normalPulse2 will be 1 
    										   secondsCount++;
                    	                  	   }
                    	                  	  
                         
    					// BAD PULSE 1 AND 2:
    					
    				
                    	   if (secondCount==2) {   						// checks if the incrementation of secondCount reaches 2 seconds for bad pulse (means 2 second has passed)
    											secondsCount = 0;             // resets the millisecond counter to 0
    											badPulse1=1;					// once it reaches 2000( 2 seconds) the badPulse1 will be 1.
    											badPulse2=1;					// once it reaches 2000( 2 seconds) the badPulse2 will be 1.
                    	                  	   }
                    	                  	   P2IFG &= ~(BIT4);           // clears the flAG
    }
    
  10. What happens if i have two ISRs : 

    1) The first one is for normal 1PPS (1Hz , 1 second)

    2) The second one is for bad pulse ( 0.5Hz , 2 seconds).

     

    do i have to define another volatile variable for the second one as well?

     

    this is the code i have been written according to what i understood from your explanation:

    i defined the clock timer d0.0 and an external oscillator of 12.8Mhz .

    the 2 ISRs are at the bottom of the code, the first ISR is for a normal 1pps (normal pulse) and the second one is for bad pulse 0.5Hz - 2 seconds (bad pulse)

    In the system i got 2 1pps output pulse 1 and pulse 2 . in every pulse you can select between on/off/bad pulse.

    #include <msp430.h>
    #include <intrinsics.h>
    
    
    
    
    volatile unsigned int timerCount = 0; //defines the millisecond counter
    volatile unsigned int normalPulse1=0; //defines another flag to indicates when 1 second has passed for normal pulse1
    volatile unsigned int badPulse1=0;//defines another flag to indicates when 1 second has passed for bad pulse1
    volatile unsigned int normalPulse2=0; //defines another flag to indicates when 1 second has passed for normal pulse2
    volatile unsigned int badPulse2=0;//defines another flag to indicates when 1 second has passed for bad pulse2
    
    int main(void) {
    
    
    	WDTCTL = WDTPW | WDTHOLD;					// Stop watchdog timer
    	P2OUT &= ~(BIT4); 							//preload 1pps to '0'
    
    
    	// set I/O pins directions
    	P1DIR |=BIT6+BIT7;                      //set p1.x to 11000000
    	P2DIR |=BIT4;	                       // Set P2.4 to output direction
        PJDIR |=BIT0+BIT1+BIT3;                // set pj.x output 0000 1011
        P2SEL |= BIT4;						   //select the option of using TD0.0 in pin 2.4
        P2IES |= BIT4;                         // high -> low is selected with IES.x = 1.
        P2IFG &= ~(BIT4);                      // To prevent an immediate interrupt, clear the flag for
                                              // P1.3 before enabling the interrupt.
        P2IE |= BIT4;                          // Enable interrupts for P2.4
    
        // Configure XT1 (external oscillator)
        PJSEL |= BIT4+BIT5;						// port select for xt1
        UCSCTL6 &= ~(XT1OFF); 				    //xt1 is on
        UCSCTL3 = 0;                            // FLL REFERENCE CLOCK REFERENCE = XT1
    
        // configure TD0.0 to output of 1 pulse per second
        TD0CTL0 |=MC_1+ID_3+TDSSEL_0+TDIE+CNTL_0+TDCLR;                //defining timer d TD0.0 (P2.4)
        TD0CCR0=1600-1;                          // setting TAR count up value 1600 (12.8MHz / 8 = 1.6MHz , 1.6MHz / 1600 = 1000 Hz) when 1000 is passed means 1 second has passed as well
        TD0CCTL0 |= CCIE;                        //ENABLES CCIFG INTERUPT ON CCR0
    
    
        __enable_interrupt();
    
    
        for(;{                      // main loop (looping forever)
    
    
    
        	//   EXTERNAL / INTERNAL SELECTION BY SW4
    
        	if ((P2IN & BIT2)==0){         //  INTERNAL MODE
        		PJOUT |=BIT3;              // sends '1' from pj.3 output to the multiplexer U4 (uses the internal 1pps)
    
        		//PULSE 1 : DESCRETE ON/OFF AND SWITCH ON/BAD/OFF
    
                         if ((P2IN & BIT0)==0 || (P1IN & BIT0)==0) {        //NORMAL SIGNAL OF 1PPS checks if descrete source is on or 1pps sw pulse 1 is on
                        	 P1OUT |= BIT6; 									//ENABLES PULSE BY THE 'AND' GATE
                        	 PJOUT |= BIT0;									//ENABLES TTL TO RS232 CONVERTER (FOR DIFF OUTPUT)
                              if(normalPulse1==1){                       //checks if normalPulse1 is on from the ISR
    						    normalPulse1 =0;                           // sets normalPulse1 to 0 again so the ISR will generate the pulse 
    						    P2OUT ^=BIT4;                            //generates 1pps out of p2.4
    						 }
    
                    	 }
                       
                         else {
                        	 P1OUT |= ~(BIT6); 								//DISABLES PULSE BY SENDING A '0' TO THE AND GATE
                         }
    
                         if ((P1IN & BIT2)==0)  {							//PULSE 1 BAD SIGNAL checks if the 1pps sw bad pulse is on
                        	  P1OUT |= BIT6; 									//ENABLES PULSE BY THE 'AND' GATE
                        	  PJOUT |= BIT0;									//ENABLES TTL TO RS232 CONVERTER (FOR DIFF OUTPUT)
    						    if(badPulse1==1){                             //checks if badPulse1 is on from the ISR
    							  badPulse1=0;                                // sets badPulse1 to 0 again so the ISR will generate the pulse
    							  P2OUT ^=BIT4;                            //generates 1pps out of p2.4
    							
    							}
                         }
    
                         //PULSE 2 : DESCRETE ON/OFF AND SWITCH ON/BAD/OFF
    
    
                         if ((P2IN & BIT1)==0 || (P1IN & BIT0)==0){			//NORMAL SIGNAL OF 1PPS checks if descrete source is on or 1pps sw pulse 2 is on
                        	 P1OUT |= BIT7; 									//ENABLES PULSE BY THE 'AND' GATE
                        	 PJOUT |= BIT1;	 								//ENABLES TTL TO RS232 CONVERTER (FOR DIFF OUTPUT)
    							if(normalPulse2==1){
    								normalPulse2=0;								// sets normalPulse2 to 0 again so the ISR will generate the pulse
    								P2OUT ^=BIT4;                            //generates 1pps out of p2.4
    							
    							}
    
    
                         }
    
    
        	
                         else {
                        	 P1OUT |= ~(BIT7);									//DISABLES PULSE BY SENDING A '0' TO THE AND GATE
                         }
    
                         if ((P1IN & BIT3)==0){								//PULSE 2 BAD SIGNAL 
                        	  P1OUT |= BIT6; 									//ENABLES PULSE BY THE 'AND' GATE
                        	  PJOUT |= BIT0;									//ENABLES TTL TO RS232 CONVERTER (FOR DIFF OUTPUT)
    							if(badPulse2==1){
    								badPulse2=0;								// sets badPulse2 to 0 again so the ISR will generate the pulse
    								P2OUT ^=BIT4;                            //generates 1pps out of p2.4
    							}
                         }
    
    
                         }
    
        	else {																//EXTERNAL MODE
        		PJOUT |= ~(BIT3);            //sends '0' from pj.3 output to the multimplexer U4 (uses the external 1pps)
        		P1OUT |= BIT6;      			// ENABLES PULSE 1
        		P1OUT |= BIT7;				//ENABLES PULSE 2
        		PJOUT |= BIT0;				//ENABLES RS422 DIFF OUTPUT	FOR PULSE 1
        		PJOUT |= BIT1;				// ENABLES RS422 DIFF OUTPUT FOR PULSE 2
        	    	}
        	}
    }
    
    	return 0;
    	
                        //ISR FOR TIMERD0.0 - NORMAL PULSE 1 AND 2
    					
    					#pragma vector = TIMER0_D0_VECTOR 				//GENERATES 1PPS EVERY 1s for normal pulse
                       __interrupt void TIMER0_D0 (void){
                    	   if (++timerCount > 500) {   						// checks if the incrementation of timerCount reaches 500 (means 1 second has passed)
    					                       timerCount = 0;             // resets the millisecond counter to 0
    										   normalPulse1 = 1;             //once it reaches 1000 (1 second) normalPulse1 will be 1 
    										   normalPulse2=1;				//once it reaches 1000 (1 second) normalPulse2 will be 1 
                    	                  	   }
                    	                  	   P2IFG &= ~(BIT4);           // clears the flAG
                         }
    					
    					
    					//ISR FOR TIMERD0.0 - BAD PULSE 1 AND 2
    					
    					#pragma vector = TIMER0_D0_VECTOR 				//GENERATES 1pulse EVERY 2s (0.5Hz) for bad pulse
                       __interrupt void TIMER0_D0 (void){
                    	   if (++timerCount > 1000) {   						// checks if the incrementation of timerCount reaches 1000 (means 2 second has passed)
    											timerCount = 0;             // resets the millisecond counter to 0
    											badPulse1=1;					// once it reaches 2000( 2 seconds) the badPulse1 will be 1.
    											badPulse2=1;					// once it reaches 2000( 2 seconds) the badPulse2 will be 1.
                    	                  	   }
                    	                  	   P2IFG &= ~(BIT4);           // clears the flAG
    
    
  11. Thanks for the reply .

    The ISR function should be out of the mian function , so if i want to generate that 1pps (after 1000 counts) in a condition: if ((P2IN & BIT2)==0) that is located inside the main function , how do i do that? how do make that connection so if the expression above is true it generates the ISR if its false it won't generate the ISR and there will be no pulse? and i have like 4 different conditions that needs to generate the pulse , how do i make that connection from the ISR to every condition inside the main function?

    This is the code that i have written according to your previous post (the short version) :

    #include <msp430.h>
    #include <intrinsics.h>
    
    unsigned int timerCount = 0; //defines the millisecond counter
    
    int main(void) {                                                    //main function
     // configure TD0.0 to output of 1 pulse per second
    
        TD0CTL0 |=MC_1+ID_3+TDSSEL_0+TDIE+CNTL_0+TDCLR;                //defining timer d TD0.0 (P2.4)
        TD0CCR0=1600-1;                                                // setting TAR count up value 1600 (12.8MHz / 8 = 1.6MHz , 1.6MHz / 1600 = 1000 Hz) when 1000 is passed means 1 second has passed as well
        TD0CCTL0 |= CCIE;                                              //ENABLES CCIFG INTERUPT ON CCR0
    
    
        __enable_interrupt();
    
    for(;{                      // main loop (looping forever)
    
    // some conditions code generating the 1pps
    
          }
    }
    return 0;
    
    // ISR for TIMERD0.0:
    
                         #pragma vector = TIMER0_D0_VECTOR 				//GENERATES 1PPS EVERY 1s
                       __interrupt void TIMER0_D0 (void){
                    	   if (++timerCount > 1000) {   						// checks if the incrementation of timerCount reaches 1000 (means 1 second has passed)
                    	                  	   P2OUT ^=BIT4;               //generates 1pps out of p2.4
                    	                  	   timerCount = 0;             // resets the millisecond counter to 0 
                    	                  	   }
                    	                  	   P2IFG &= ~(BIT4);           // clears the flAG
                         }
    
    
    
    
  12. Thanks for the reply , is there another way of doing this within the main function without using interupts? like using TDIFG only?

    is there a document that sums up all the code functions? because i have encountered the code :  

    that code uses timer A and it looks easier using flags instead of interupts.

    #include <io430x11x1.h> // Specific device// Pins for LEDs#define LED1 BIT3#define LED2 BIT4void main (void){WDTCTL = WDTPW|WDTHOLD; // Stop watchdog timerP2OUT = 
  13. Hello ,
    I'm new to this field of microcontroller and i need you quick help with a new project of mine.
     
    I'm using MSP430F5131.
    I will explain a little about the project :
    My main goal is to generate a 1 pulse per second  using a 12.8MHz external oscillator.
    I already have a printed PCB for that project which means i got to understand what the previous designer had done and implement it into my CCS program in order to program my micro controller.
    i am still new to this whole microcontroller world and im eager to know more , although im short in time.
     
    I have attached an electrical wiring of the PCB to help you understand a little bit more about the project.
     
    A little explanation of the electrical wiring:
    An external toggle switch (from connector J6 "Internal/External Selection") switch between an external 1pps (From an external GPS) or internal 1pps (by the msp430).
    if we choose an internal mode then (input P2.2) a '1' (or '0' if its an active low mode which is an active low mode) sends from PJ.3 (ouput) to U4 and a 1 pulse per second gets out of P2.4 output to connectors J8 and J9 (same pulse different connectors).
     
    I can Switch signals to ON/BAD/OFF by using an external toggle switch(pins 1,2 of J3 connector) or a descrete (pin 3 of J3 connector).
    if i toggle the switch to on mode it sends '1'(or '0' if its an active low mode which is an active low mode) through P1.6 to U5 ( And Gate) and enables the pulse it also sends '1' through PJ.0 to U6 and converts the pulse from TTL to RS422 (differetial).
    The descrete switching option switches the pulse (ON/OFF) the same as the external toggle switch.
    This is refers to PULSE 1 , i need to implement the same thing for PULSE 2.
     
    although im still not sure what RST/NMI/SBWTDIO and TEST/SBWTCK are wired for , are these for downloading the program into the msp?
    im also not sure about the PJ.2 pin (FUNCTIONALITY DISABLE).
     
    I know its a lot to read but im really short in time about this project and i dont have much time to study everything.
    so i would be very glad if you could read the code and help me implement the functions into the code.
     
    I know that in the following code i used interupts with #pragma function . although i heard that #pragma function cannot be located in the main function - i need to generate that 1pps pulse in some conditions (which mentioned in the code under 'if' statement)  but i cant use that ISR function inside the code so how can i do that? and is there another way of doing that without using interupts that can generate the same 1 pps?
     
    here's the code :
    #include <msp430.h>
    #include <intrinsics.h>
    
    
    
    
    unsigned int timerCount = 0;
    
    int main(void) {
    
    
    	WDTCTL = WDTPW | WDTHOLD;					// Stop watchdog timer
    	P2OUT &= ~(BIT4); 							//preload 1pps to '0'
    
    
    	// set I/O pins directions
    	P1DIR |=BIT6+BIT7;                      //set p1.x to 11000000
    	P2DIR |=BIT4;	                       // Set P2.4 to output direction
        PJDIR |=BIT0+BIT1+BIT3;                // set pj.x output 0000 1011
        P2SEL |= BIT4;							//select the option of using TD0.0 in pin 2.4
        P2IES |= BIT4;                        // high -> low is selected with IES.x = 1.
        P2IFG &= ~(BIT4);                          // To prevent an immediate interrupt, clear the flag for
                                              // P1.3 before enabling the interrupt.
        P2IE |= BIT4;                          // Enable interrupts for P1.3
    
        // Configure XT1 (external oscillator)
        PJSEL |= BIT4+BIT5;						// port select for xt1
        UCSCTL6 &= ~(XT1OFF); 				    //xt1 is on
        UCSCTL3 = 0;                            // FLL REFERENCE CLOCK REFERENCE = XT1
    
        // configure TD0.0 to output of 1 pulse per second
    
        TD0CCR0=16000-1;                          // setting TAR count up value 16000 (12.8MHz / 8 = 1.6MHz , 1.6MHz / 100 = 16000 Hz) when 100 is passed means 1 second has passed as well
        //TD0CCR1= 								//DUTY CYCLE OF 50%
        //TD0CCTL1=CCIE + OUTMOD_7;                    //enabling interuption + RESET/SET OUTPUT MODE
        TD0CTL0 =MC_2+ID_3+TDSSEL_0+TAIE;                //defining timer d TD0.0 (P2.4)
    
        __enable_interrupt();
    
    
        for(;{                      // main loop (looping forever)
    
    
    
        	//   EXTERNAL / INTERNAL SELECTION BY SW4
    
        	if ((P2IN & BIT2)==0){         //  INTERNAL MODE
        		PJOUT |=BIT3;              // sends '1' from pj.3 output to the multiplexer U4 (uses the internal 1pps)
    
        		//PULSE 1 : DESCRETE ON/OFF AND SWITCH ON/BAD/OFF
    
                         if ((P2IN & BIT0)==0 || (P1IN & BIT0)==0) {        //NORMAL SIGNAL OF 1PPS checks if descrete source is on or 1pps sw pulse 1 is on
                        	 P1OUT |= BIT6; 									//ENABLES PULSE BY THE 'AND' GATE
                        	 PJOUT |= BIT0;									//ENABLES TTL TO RS232 CONVERTER (FOR DIFF OUTPUT)
    						#pragma vector = TIMER0_D0_VECTOR
                        	 __interrupt void TIMER0_D0(void){
                    	   if (++timerCount > 20) {  						 // checks if the incrementation of timerCount reaches 50 (means 0.5 second has passed)
    										   P2OUT ^=BIT4;               //generates 1pps out of p2.4
    										   timerCount = 0;             // resets the timer count
    										   }
    										   P2IFG &=~(BIT4);             // clears the fl
                        	 }
    
                    	 }
                       }
                         else {
                        	 P1OUT |= ~(BIT6); 								//DISABLES PULSE BY SENDING A '0' TO THE AND GATE
                         }
    
                         if ((P1IN & BIT2)==0)  {							//PULSE 1 BAD SIGNAL ???
                        	 // CODE HERE FOR BAD SIGNAL PULSE 1//
                         }
    
                         //PULSE 2 : DESCRETE ON/OFF AND SWITCH ON/BAD/OFF
    
    
                         if ((P2IN & BIT1)==0 || (P1IN & BIT0)==0){			//NORMAL SIGNAL OF 1PPS checks if descrete source is on or 1pps sw pulse 2 is on
                        	 P1OUT |= BIT7; 									//ENABLES PULSE BY THE 'AND' GATE
                        	 PJOUT |= BIT1;	 								//ENABLES TTL TO RS232 CONVERTER (FOR DIFF OUTPUT)
    					#pragma vector = TIMER0_D0_VECTOR 				//GENERATES 1PPS EVERY 1s
                       __interrupt void TIMER0_D0 (void){
                    	   if (++timerCount > 20) {   						// checks if the incrementation of timerCount reaches 100 (means 1 second has passed)
                    	                  	   P2OUT ^=BIT4;               //generates 1pps out of p2.4
                    	                  	   timerCount = 0;             // resets the timer count
                    	                  	   }
                    	                  	   P2IFG &= ~(BIT4);             // clears the fl
                         }
    
    
        	}
                         else {
                        	 P1OUT |= ~(BIT7);									//DISABLES PULSE BY SENDING A '0' TO THE AND GATE
                         }
    
                         if ((P1IN & BIT3)==0){								//PULSE 1 BAD SIGNAL ???
                        	 // CODE HERE FOR BAD SIGNAL PULSE 1//
                         }
    
    
                         }
    
        	else {																//EXTERNAL MODE
        		PJOUT |= ~(BIT3);            //sends '0' from pj.3 output to the multimplexer U4 (uses the external 1pps)
        		P1OUT |= BIT6;      			// ENABLES PULSE 1
        		P1OUT |= BIT7;				//ENABLES PULSE 2
        		PJOUT |= BIT0;				//ENABLES RS422 DIFF OUTPUT	FOR PULSE 1
        		PJOUT |= BIT1;				// ENABLES RS422 DIFF OUTPUT FOR PULSE 2
        	    	}
        	}
    }
    
    
    	return 0;
    
    
    
    
    

    Thanks in advance.

    PCB electrical wiring.pdf

×
×
  • Create New...