What's the defference between these 2 codes?

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
Wakeup:
	sleep ; send to sleep
	nop ; after wakeup
	rjmp Wakeup

and

Wakeup:
	sleep ; send to sleep
	
	rjmp Wakeup

I mean, when the MCU woke up for some reason, where would the program point to go - to any interrupt vector entry, to the main portion, or to the "Wakeup" signed place in upper 2 codes?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You may want to post some context.

John Samperi

Ampertronics Pty. Ltd.

https://www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

An interrupt is required to wake the AVR. The AVR will call the isr of the interrupt that woke it up. What does the datasheet say?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

And the ISR will return to the next line of code after the "sleep" statement.

 

nop may be desirable in some cases for things to "stabilize" after waking up. This will likely depend very strongly on the MCU and will certainly depend strongly on which of the several sleep modes is used. Thus, there is no universal answer about the nop.

 

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

js wrote:

You may want to post some context.

 

    ;
    ; *****************************************
    ; * Blink LED with timer at 128 kcs clock *
    ; *****************************************
    ;
    .NOLIST
    .INCLUDE "tn13def.inc"
    .LIST
    ;
    ; ------- Register -----------------------
    .def rmp = R16 ; multi purpose register
    ;
    ; ------- Timing -------------------------
    ; Internal RC oscillator   = 128.000 cs/s
    ; Clock prescler CLKPR     =       1
    ; Internal clock frequency = 128.000 cs/s
    ; TC0 prescaler            =     256
    ; TC0 timer tick           =     500 cs/s
    ; TC0 CTC divider          =     250
    ; TC0 toggle frequency     =       1 cs/s
    ;
    ; --------- Constants --------------------
    .equ cCtc = 250-1
    ;
    ; --------- Programm ---------------------
    	; PB0 as output
    	sbi DDRB,DDB0 ; Port bit as output
    	; Timer Compare Match A to 250
    	ldi rmp,cCtc ; Match A value
    	out OCR0A,rmp ; to Match port A
    	; Timer as CTC and toggle output A
    	ldi rmp,(1<<COM0A0)|(1<<WGM01) ; Toggle and CTC
    	out TCCR0A,rmp ; to timer control port A
    	ldi rmp,1<<CS02 ; Prescaler to 256
    	out TCCR0B,rmp ; to timer control port B
    	; Sleep mode
    	ldi rmp,1<<SE ; Sleep mode idle
    	out MCUCR,rmp ; to universial control port
    	; Sleep loop
    Wakeup:
    	sleep ; send to sleep
    	nop ; after wakeup
    	rjmp Wakeup
    ;
    ; End of source code
    ;

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It might have helped if you had simply made the link to the page where you got this:

 

http://www.avr-asm-tutorial.net/...

 

I'd suggest the person to ask is the person who wrote that code/article. I have a feeling the NOP may simply be there as an instruction to breakpoint on but perhaps the author will be able to tell you of some deeper reason he thought it was necessary ?

 

According to this linked page:

 

http://www.gsc-da.de/

 

his email could well be:

info (ersetzen) gsc-da.de

I have a feeling that ersetzen may be the German word for the "at" symbol.

Last Edited: Mon. Feb 1, 2021 - 10:10 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Shouldn't you at least toggle a pin to show yourself that it actually woke up?  what are you hoping to do?

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


avrcandies wrote:
what are you hoping to do?
See my link in #6 it's just listed straight from a tutorial: