Question

;------------------------------------------------------------------------------- ; MSP430 Assembler Code Template for use with TI Code Composer Studio ; ; ;-------------------------------------------------------------------------------...

;-------------------------------------------------------------------------------
; MSP430 Assembler Code Template for use with TI Code Composer Studio
;
;
;-------------------------------------------------------------------------------
.cdecls C,LIST,"msp430.h" ; Include device header file
  
;-------------------------------------------------------------------------------
.def RESET ; Export program entry-point to
; make it known to linker.
;-------------------------------------------------------------------------------
.text ; Assemble into program memory.
.retain ; Override ELF conditional linking
; and retain current section.
.retainrefs ; And retain any sections that have
; references to current section.

;-------------------------------------------------------------------------------
RESET mov.w #__STACK_END,SP ; Initialize stackpointer
StopWDT mov.w #WDTPW|WDTHOLD,&WDTCTL ; Stop watchdog timer


;-------------------------------------------------------------------------------
; Main loop here
;-------------------------------------------------------------------------------
       bis.b #11111111b, &P1DIR
       bic.b #11111111b, &P1OUT

loop_1:
       bis.b #11101111b, &P1OUT ; 9
    bis.b @R11, &P1OUT
       push.w R11
       call #delay
       pop.w R11

       bis.b #01111111b, &P1OUT ; 8
       bis.b @R11, &P1OUT
       push.w R11
       call #delay
       pop.w R11

       bis.b #00000111b, &P1OUT ; 7
       call #delay

       bis.b #11111101b, &P1OUT ; 6
       call #delay

       bis.b #11101101b, &P1OUT ; 5
       call #delay

       bis.b #01100110b, &P1OUT ; 4
       call #delay

       bis.b #01001111b, &P1OUT ; 3
       call #delay

       bis.b #01011011b, &P1OUT ; 2
       call #delay

       bis.b #00000110b, &P1OUT ; 1
       call #delay

       bis.b #00111111b, &P1OUT ; 0
       call #delay

delay
      
       mov #0, R5
       mov #0, R4

odd_even:
           ;Over here i need to count number of 1's in binary but cant figure out how to do it
           jnz try
           jz delay_over


try:
       bic.b #01111111b, &P1OUT
       bis.b #00111111b, &P1OUT ; 0
       jmp continue
delay_over:
           inc R4

keep_delay:
           inc R5
           cmp #1000000, R5
           jne keep_delay
           cmp #3, R4
           jne delay_over
           bic.b #01111111b, &P1OUT


           jmp continue

continue


   ret

;-------------------------------------------------------------------------------
; Stack Pointer definition
;-------------------------------------------------------------------------------
.global __STACK_END
.sect .stack
  
;-------------------------------------------------------------------------------
; Interrupt Vectors
;-------------------------------------------------------------------------------
.sect ".reset" ; MSP430 RESET Vector
.short RESET
  
Hi, i have homework where i should count number of 1's in binary that i set which have odd number then i need to display this on 7 segment display. On the code i wrote a comment where i should do this. I am working with texas insturment msp430.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

mov.b   #0,r12
clrc    
rrc.b     r13           
L1:          
    addc    #0, r12        
    rrc.b   r13            
    jnz    L1

addc    #0, r12       

( result is in r12)

Add a comment
Know the answer?
Add Answer to:
;------------------------------------------------------------------------------- ; MSP430 Assembler Code Template for use with TI Code Composer Studio ; ; ;-------------------------------------------------------------------------------...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C CODE LANGUAGE. MSP430. #include <msp430fr6989.h> #define redLED BIT0 // Red LED at P1.0 #define greenLED...

    C CODE LANGUAGE. MSP430. #include <msp430fr6989.h> #define redLED BIT0 // Red LED at P1.0 #define greenLED BIT7 // Green LED at P9.7 #define BUT1 BIT1 // Button S1 at P1.1 #define BUT2 BIT2 // Button S2 at P1.2 void main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop the Watchdog timer PM5CTL0 &= ~LOCKLPM5; // Enable the GPIO pins // Configure and initialize LEDs P1DIR |= redLED; // Direct pin as output P9DIR |= greenLED; // Direct pin as output...

  • You have to put the input to the line(Linea), rectangle(rectangulo), triangle(triangulo) and circle(circulo) in assembly 8086...

    You have to put the input to the line(Linea), rectangle(rectangulo), triangle(triangulo) and circle(circulo) in assembly 8086 please, Same as this code, add that input that I'm asking. Which user of the size and the area where the figure will be located on the screen. .MODEL SMALL   .STACK 100h .DATA    mensaje db 'Seleccione una opcion del siguiente Menu',13, 10        db '1. Dibujar un Circulo', 13, 10        db '2. Dibujar una Linea', 13, 10        db '3. Dibujar un...

  • I need help with doing these tasks for code composer Lab 3 - Branching, Push Button...

    I need help with doing these tasks for code composer Lab 3 - Branching, Push Button and LEDs-Reading Assignment in this lab, we are going to control a LED via a push button- using general purpose digital 10 for both input (button) and output (LED) on port 1 - using Code Composer Studio. Furthermore, we are going to use a branch instruction to create an IF-ELSE structure in assembly to determine if the LED should be lit up based on...

  • Implement the following statements using MS430 assembly instructions. You may use more than one, ...

    Implement the following statements using MS430 assembly instructions. You may use more than one, but you should minimize the number of instructions required. You can use both native and emulated instructions. Use hex notation for all numbers 1. (a) Move the word located in register R14 to R15 (b) Increment the word in R6 by 2. (c) Perform a bitwise ANDing of the word located at address 0x0240 with the datum in R15, placing the results in R15. (d) Rotate...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT