Arduino

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For this lab experiment you will create a program that uses only inline assembly ,you will need to reference the Instruction Set Summary from the ATmega328P data sheet.
1. Your program must configure PB0 as an input with internal pull-up enabled.
2. Your program must configure PB1 as an output.
3. Implement the equivalent of the infinite while loop in assembly
4. Inside the infinite while loop read PB0 and write the same value to PB1.

What is wrong with the code?

 

 

 

// Includes
#include <stdint.h>
// Defines
int main()
{
  init();

  Serial.begin(9600);
  Serial.write("Start of program/n");
  
            asm volatile("ldi r16, 0x02    \n\t" 
             "sts 0x25, r16    \n\t");// PORTB = 0000 0001 turn on internal pull-up on PB0
            asm volatile( "ldi r16, 0x01    \n\t"
                "sts 0x24, r16    \n\t");// DDRB = 0000 0010)
        //while(1){
           asm volatile( "lds r16, 0x23    \n\t"    // read PINB
                         "sbrc r16, 0  \n\t"
                         "jmp loop1  \n\t");
           asm volatile("movw r16,0x23  \n\t"   //copy from PINB
                        "sts 0x24,r17  \n\t");
                  
                 return 0;
                 
}

Last Edited: Tue. Dec 17, 2019 - 05:46 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It's the same assignment already under discussion here: https://www.avrfreaks.net/forum/...

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

I know it's the same, I don't know what is wrong with the code!!1

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

Interesting how it's pretty much exactly the same code.

 

I'd guess the OP of the other thread and qwqwq09 are the same person.  If they're not, then they're equally bad at listening to advice.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

Hmmmmm....

 

Two different IP addresses, different users, same code.  Same requirements.

 

IP detection shows from the same geographic area.

 

I'll lock this and the OP can either stick to the other thread, or prove to me they are a different person.

 

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

Topic locked