mercredi 10 mars 2021

How to write assembly language code in CCS that allows for an LED to flash a specific amount of times based on switches being pressed?

Next, write a program in main that calls your subroutine to flash the green LED at two different rates based on whether switch 1 pressed or not:

  • Left button (SW1) not pressed: green LED flashes at a rate of once per second. On for one second off for one second then the sequence repeats as long as the button is not pressed.
  • LEFT button pressed: green LED flashes at a rate of 10 times per second. On for one 0.1 seconds off for 0.1 seconds then the sequence repeated as long as the button is pressed.

flash_led_diffrates: .asmfunc

LDR R1, GPIO_PORTF_DATA_R
LDR R0, [R1]
AND R0, R0, #0x1000
STR R0, [R1]
BL delay
SUB R0, #0x10000
BL delay

BX LR

.endasmfunc

Aucun commentaire:

Enregistrer un commentaire