OPERAND 1 OUT OF RANGE: 0x7A

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

Hello, I have 5 errors in my code, I need to show in LCD temperature, but when I check the code, Atmel Studio said me that OPERAND 1 OUT OF RANGE: 0x6e,  OPERAND 1 OUT OF RANGE: 0x7A, OPERAND 2 OUT OF RANGE: 0x78, OPERAND 2 OUT OF RANGE: 0x79, I cant found the solution of this problem, somebody can help me, please?

 

 

 

MAIN:

NOP

LDI R16, HIGH(RAMEND)

OUT SPH, R16

LDI R16, LOW(RAMEND)

OUT SPH, R16

 

LDI R16, -255

OUT TCNT0, R16

LDI R16, 0x02

OUT TCCR0B, R16

LDI R16, (1<<TOIE0)

OUT TIMSK0, R16

 

CLR R16

LDI R16, 0B01100011 

STS 0x7C, R16 

 

 

LDI R16, 0B11001111 

STS ADCSRA, R16 

 

 

 

CALL LCD_Init

CALL MSGDISP

LDI R16, 0x0C

CALL CMNDWRT

SEI

Last Edited: Sun. Oct 8, 2017 - 08:22 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

1. Tell us what AVR model you're using.

 

2. Please, quote the error messages verbatim, and show what lines generates the respective errors.

I have 5 errors in my code

But you show us only four of those...

 

3. This makes no sense:

LDI R16, -255

R16 is eight bits. The (signed) value range for an 8-bit byte is -128..+127. 

 

The value -255 implies nine bits! If you simply want all bits in the byte set then 0xFF should do it. Or -127, if you want to be cryptic about  it.

Happy 75th anniversary to one of the best movies ever made! Rick Blane [Bogart]: "Of all the gin joints, in all the towns, in all the world, she walks into mine."

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

Last Edited: Sun. Oct 8, 2017 - 08:51 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The address you use for OUT is different to the address used in STS. The datasheet explains this. 

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

JohanEkdahl wrote:

1. Tell us what AVR model you're using.

 

2. Please, quote the error messages verbatim, and show what lines generates the respective errors.

I have 5 errors in my code

But you show us only four of those...

 

3. This makes no sense:

LDI R16, -255

R16 is eight bits. The (signed) value range for an 8-bit byte is -128..+127. 

 

The value -255 implies nine bits! If you simply want all bits in the byte set then 0xFF should do it. Or -127, if you want to be cryptic about  it.

Im sorry for not especific information, Im using atmega 2560, and all errors are:

Severity Code Description Project File Line Source

Error Operand 1 out of range: 0x6e LAB2_V2 D:\Universidad\Microprocesadores\Microprocesadores\ESTUDIO DE PROMACIËN\LAB2_V2\LAB2_V2\main.asm 43 Build

Severity Code Description Project File Line Source

Error Operand 1 out of range: 0x7a LAB2_V2 D:\Universidad\Microprocesadores\Microprocesadores\ESTUDIO DE PROMACIËN\LAB2_V2\LAB2_V2\main.asm 74 Build

Severity Code Description Project File Line Source

Error Operand 2 out of range: 0x78 LAB2_V2 D:\Universidad\Microprocesadores\Microprocesadores\ESTUDIO DE PROMACIËN\LAB2_V2\LAB2_V2\main.asm 79 Build

Severity Code Description Project File Line Source

Error Operand 2 out of range: 0x79 LAB2_V2 D:\Universidad\Microprocesadores\Microprocesadores\ESTUDIO DE PROMACIËN\LAB2_V2\LAB2_V2\main.asm 80 Build

Severity Code Description Project File Line Source

Error Wrong number of operands LAB2_V2 D:\Universidad\Microprocesadores\Microprocesadores\ESTUDIO DE PROMACIËN\LAB2_V2\LAB2_V2\main.asm 101 Build

 

I'll be very greatful, I'll leave my code down here:

 

.include "m2560def.inc" 

 

.ORG 0x00

 

.EQU LCD_PRT = PORTA  ;

.EQU LCD_DDR = DDRA ;

.EQU LCD_PIN = PINA ;

.EQU LCD_RS = 0  ;

.EQU LCD_RW = 1

.EQU LCD_EN = 2

 

RJMP MAIN

 

.ORG ADCCaddr

RJMP ADC_INT_HANDLER

 

.ORG 0x2E

RJMP TIMER0_INT

 

;*************************************************************

.ORG 0x100

MAIN:

NOP

LDI R16, HIGH(RAMEND)

OUT SPH, R16

LDI R16, LOW(RAMEND)

OUT SPH, R16

 

LDI R16, -255

OUT TCNT0, R16

LDI R16, 0x02

OUT TCCR0B, R16

LDI R16, (1<<TOIE0)

OUT TIMSK0, R16

 

CLR R16

LDI R16, 0B01100011 ; CON EL BIT 6 SE USAN LOS 5V DEL ARDUINO, CON EL BIT 5 SE HACEN LOS 10 bits que representan la valor analógico convertido a decimal 1024.

; LOS BITS 0,1,2 Y 3 REPRESENTAN EL NUMERO DECIMAL DEL PIN QUE SE DESEA USAR QUE EN EST CASO ES ADC3 

 

STS 0x7C, R16 ; ESTO SE ESTA CONFIGURANDO EN ADMUX

 

 

LDI R16, 0B11001111 ; CUANDO EL BIT 7 ESTA EN 1 EL ADC ESTA ENCENDIDO, EL BIT 6 PARA HACER CONVERSIÓN A-D, EL BIT 5 ESTA EN 0 PORQUE NO SE HABILITARA LA CONVERSIÓN AUTOMATICA,

; EL BIT 4 SE PONE A 0 PARA QUE DETECTE SOLO LA INTERRUPCIÓN DEL ADC, EL BIT 3 SE PONE A 1 PARA HABILITAR LA INTERRUPCION DEL ADC, (PRESCALER 128)

; PARA OBTENER UNA FRECUENCIA DE MUESTREO DE 125KHZ 

STS ADCSRA, R16 ; ADCSRA  

 

 

 

CALL LCD_Init

CALL MSGDISP

LDI R16, 0x0C

CALL CMNDWRT

SEI ; ACTIVAR INTERRUPCIONES GLOBALES

 

HERE:

NOP

RJMP HERE

MSG: .DB "TEMPERATURA: ",0

;******************************************************************

.ORG 0x250

TIMER0_INT:

SBI ADCSRA, ADSC ;COMIENZO DEL ADC, PRIMERA VEZ EL TOMARA 25/26 CICLOS DE RELOJ DEL ADC

RETI

 

.ORG 0x300

ADC_INT_HANDLER:

IN R17, ADCL ;LEE EL VALOR BAJO DEL LOS 8 BITS DEL ADC

IN R16, ADCH ;LEE EL VALOR ALTO DE LOS 8 BITS DEL ADC

CALL CONVERSION

MOV R16, R1

CALL DATAWRT

MOV R16, R0

CALL DATAWRT

 

; VOLVER A DOS PUNTOS DEL CURSOR

LDI R16, 0x10

CALL CMNDWRT

LDI R16, 0x10

CALL CMNDWRT

RETI

 

;********************************************************

; CONVERTIR LOS VALORES ENTREGADOS POR EL ADC EN SU CORRESPONDIENTE VALOR EN DECIMAL

CONVERSION:

LDI R17, 0x00

MOV R0, R17

MOV R1, R17

CPI R16, 0x0A

BRBS H1

H0:

SUBI R16, 0x0A

INC R1

CPI R16, 0x0A

BRSH H0

LDI R17, 0x30

OR R1, R17

H1:

MOV R0, R16

LDI R17, 0x30

OR R0, R17

RET

 

;**********************************************************************************

 

 

 

 

;************************************************************************

LCD_Init:

LDI R21, 0xFF

OUT LCD_DDR, R21 ; PUERTO DE DATOS ES SALIDA PARA EL LCD

 

LDI R16, 0x33 ; INICIALICE EL LCD PARA DATOS DE 4 BITS

CALL CMNDWRT

CALL DELAY_2ms

LDI R16, 0x32 ; INICIALICE EL LCD PARA DATOS DE 4 BITS

CALL CMNDWRT

CALL DELAY_2ms

LDI R16, 0x28 ; 2 LINEAS, 5X7 MATRIZ

CALL CMNDWRT

CALL DELAY_2ms

LDI R16, 0x0E ; DISPLAY ENCENDIDO, CURSOR ENCENDIDO

CALL CMNDWRT

CALL DELAY_2ms

LDI R16, 0x01 ; LIMPIA LCD 

CALL CMNDWRT

CALL DELAY_2ms

LDI R16, 0x06 ; DESPLAZA CURSOR A LA DERECHA

CALL CMNDWRT

RET

;*************************************************************************

 

MSGDISP:

 

LDI R31, HIGH(MSG<<1)

LDI R30, LOW(MSG<<1)

LOOP:

LPM R16, Z+

CPI R16, 0

BREQ HERE1

CALL DATAWRT

RJMP LOOP

HERE1:

RET

;***************************************************************************

CMNDWRT:

  MOV  R27, R16

  ANDI R27, 0xF0

  IN  R26, LCD_PRT

  ANDI R26, 0x0F

  OR  R26, R27

  OUT  LCD_PRT, R26

  CBI  LCD_PRT, LCD_RS

  CBI  LCD_PRT, LCD_RW

  SBI  LCD_PRT, LCD_EN

  CALL SDELAY

  CBI  LCD_PRT, LCD_EN

 

  CALL DELAY_100us 

 

  MOV  R27, R16

  SWAP R27

  ANDI R27, 0xF0

  IN  R26, LCD_PRT

  ANDI R26, 0x0F

  OR  R26, R27

  OUT  LCD_PRT, R26

  SBI  LCD_PRT, LCD_EN

  CALL SDELAY

  CBI  LCD_PRT, LCD_EN

 

  CALL DELAY_100us

  RET

 

DATAWRT:

  MOV  R27, R16

  ANDI R27, 0xF0

  IN  R26, LCD_PRT

  ANDI R26, 0x0F

  OR  R26, R27

  OUT  LCD_PRT, R26

  SBI  LCD_PRT, LCD_RS //RS=1 for data write else it is 0

  CBI  LCD_PRT, LCD_RW

  SBI  LCD_PRT, LCD_EN

  CALL SDELAY

  CBI  LCD_PRT, LCD_EN

 

 

  MOV  R27, R16

  SWAP R27

  ANDI R27, 0xF0

  IN  R26, LCD_PRT

  ANDI R26, 0x0F

  OR  R26, R27

  OUT  LCD_PRT, R26

  SBI  LCD_PRT, LCD_EN

  CALL SDELAY

  CBI  LCD_PRT, LCD_EN

 

  CALL DELAY_100us

  RET

 

 

SDELAY: 

  NOP

  NOP

  RET

 

DELAY_100us:

    ldi  r18, 3

    ldi  r19, 19

L2: dec  r19

    brne L2

    dec  r18

    brne L2

 

DR0: CALL SDELAY

  DEC  R17

  BRNE DR0

  POP  R17

  RET

 

  DELAY_2ms: 

    ldi  r18, 42

    ldi  r19, 142

L1: dec  r19

    brne L1

    dec  r18

    brne L1

    nop

 

 

Last Edited: Sun. Oct 8, 2017 - 05:36 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@Kartman said:

The address you use for OUT is different to the address used in STS. The datasheet explains this. 

It's in section 8.4 of the datasheet.

Greg Muth

Portland, OR, US

Atmel Studio 7.0 on Windows 10

Xplained/Pro/Mini Boards mostly

 

 

Last Edited: Sun. Oct 8, 2017 - 05:51 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Greg_Muth wrote:

@Kartman said:

The address you use for OUT is different to the address used in STS. The datasheet explains this. 

It's in section 8.4 of the datasheet.

Yeah, I change the syntaxis to STS, but the errors continue

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

I just created a test project and loaded your code and hit BUILD, and got the same errors.  All of them are very straight forward:

 

Error    1    Operand 1 out of range: 0x7a    Z:\Scratch_Pad\AssemblerApplication1\AssemblerApplication1\AssemblerApplication1.asm    133    0    AssemblerApplication1

 

 Points to:

SBI ADCSRA, ADSC ;COMIENZO DEL ADC, PRIMERA VEZ EL TOMARA 25/26 CICLOS DE RELOJ DEL ADC

 

SBI will not work on that register as it is out of the range of the lower 32 I/O registers as it explains in the Assembly help file:

 

 

Now this error:

Error    1    Operand 1 out of range: 0x6e    Z:\Scratch_Pad\AssemblerApplication1\AssemblerApplication1\AssemblerApplication1.asm    75    0    AssemblerApplication1

 

Points to this line:

out TIMSK0, R16

Again, the OUT instruction cannot operate on the register as it is not in the lower 32 I/O registers.  Use STS istead

 

 

Error    3    Operand 2 out of range: 0x78    Z:\Scratch_Pad\AssemblerApplication1\AssemblerApplication1\AssemblerApplication1.asm    143    0    AssemblerApplication1

 

 

points to:

IN R17, ADCL ;LEE EL VALOR BAJO DEL LOS 8 BITS DEL ADC

Again, IN does not operate on that register as it is out of range.  Try using LDS  instead.

 

Same thing for the other errors.

 

Now this one:

Error    5    Wrong number of operands    Z:\Scratch_Pad\AssemblerApplication1\AssemblerApplication1\AssemblerApplication1.asm    187    0    AssemblerApplication1

 

Which points to this:

BRBS H1

 YOu are missing what bit you are testing.

 

Lastly, in this routine at the very end of the code:


  DELAY_2ms: 

    ldi  r18, 42

    ldi  r19, 142

L1: dec  r19

    brne L1

    dec  r18

    brne L1

    nop

You need a RET otherwise the program dives off into nowhere.

 

Jim

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

Please Read: Code-of-Conduct

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

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

jgmdesign wrote:

I just created a test project and loaded your code and hit BUILD, and got the same errors.  All of them are very straight forward:

 

Error    1    Operand 1 out of range: 0x7a    Z:\Scratch_Pad\AssemblerApplication1\AssemblerApplication1\AssemblerApplication1.asm    133    0    AssemblerApplication1

 

 Points to:

SBI ADCSRA, ADSC ;COMIENZO DEL ADC, PRIMERA VEZ EL TOMARA 25/26 CICLOS DE RELOJ DEL ADC

 

SBI will not work on that register as it is out of the range of the lower 32 I/O registers as it explains in the Assembly help file:

 

 

Now this error:

Error    1    Operand 1 out of range: 0x6e    Z:\Scratch_Pad\AssemblerApplication1\AssemblerApplication1\AssemblerApplication1.asm    75    0    AssemblerApplication1

 

Points to this line:

out TIMSK0, R16

Again, the OUT instruction cannot operate on the register as it is not in the lower 32 I/O registers.  Use STS istead

 

 

Error    3    Operand 2 out of range: 0x78    Z:\Scratch_Pad\AssemblerApplication1\AssemblerApplication1\AssemblerApplication1.asm    143    0    AssemblerApplication1

 

 

points to:

IN R17, ADCL ;LEE EL VALOR BAJO DEL LOS 8 BITS DEL ADC

Again, IN does not operate on that register as it is out of range.  Try using LDS  instead.

 

Same thing for the other errors.

 

Now this one:

Error    5    Wrong number of operands    Z:\Scratch_Pad\AssemblerApplication1\AssemblerApplication1\AssemblerApplication1.asm    187    0    AssemblerApplication1

 

Which points to this:

BRBS H1

 YOu are missing what bit you are testing.

 

Lastly, in this routine at the very end of the code:


  DELAY_2ms: 

    ldi  r18, 42

    ldi  r19, 142

L1: dec  r19

    brne L1

    dec  r18

    brne L1

    nop

You need a RET otherwise the program dives off into nowhere.

 

Jim

 

Thank you Jim, right now I reduce 4 errors, I made some changes to the timer, but Atmel Studio show me that INVALID REGISTER LINE 84: After 1s Start ADC...  and ADSC is the register to clear the ADC, I dont understant this error. 

 

I

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

You cannot alter a bit using STS.  You will need to set up the bits in a temp register, then use the OR instruction to set the bit.

 

In your case:

LDI  TEMP, 0x40;            //Bit 6 is ADSC
OR   ADCSRA,TEMP;          //Set teh bit, leaving the others alone 

 

Untested, and I am sure others may have a better way.

 

JIm

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

Please Read: Code-of-Conduct

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

Last Edited: Sun. Oct 8, 2017 - 07:37 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

jgmdesign wrote:

You cannot alter a bit using STS.  You will need to set up the bits in a temp register, then use the OR instruction to set the bit.

 

In your case:

LDI  TEMP, 0x40;            //Bit 6 is ADSC
OR   ADCSRA,TEMP;          //Set teh bit, leaving the others alone 

 

Untested, and I am sure others may have a better way.

 

JIm

I used:

LDI R25, 0x40

OR ADCSRA, R25

 

But the error continue.

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

volterius wrote:
But the error continue.

What does the error say? 

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

Please Read: Code-of-Conduct

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

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

volterius wrote:
I used: LDI R25, 0x40 OR ADCSRA, R25   But the error continue.

Yes, bevcause the OR instruction can not handle ADCSRA, which is an I/O register. Only CPU registers (R0..R31) can be used in the OR instruction.

 

First thing you need to do when getting these errors is to look in the document AVR Instruction Set: http://www.atmel.com/Images/Atme...

 

For the OR instruction:

 

    Syntax:        Operands:                  Program Counter:
(i) OR Rd,Rr       0 ≤ d ≤ 31, 0 ≤ r ≤ 31     PC ← PC + 1

Notice the Rd and Rr notation where the "R" implies a CPU register and under "Operands" you can see which CPU registers that can be used. In the case of OR it is any of the CPU registers.

 

So you'd need to

 

1) Get the current ADCSRA value into a CPU register (R0..R31) . say Rn

2) Get the immediate value  0x40 into another register, say Rm

3) OR the value of Rm into Rn

4) Store the value in Rn into ADCSRA

 

But notice that there is also an instruction ORI that will effectively combine steps 2) ans 3) above leaving you with (sketchy, untested)

 

1) Load ADCSRA into a CPU register (Rn)

2) ORI the immediate value 0x40 into that same register

3) Store that registers value back to ADCSRA

 

Happy 75th anniversary to one of the best movies ever made! Rick Blane [Bogart]: "Of all the gin joints, in all the towns, in all the world, she walks into mine."

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

Last Edited: Sun. Oct 8, 2017 - 08:09 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

jgmdesign wrote:
What does the error say? 

 

Surely the same "Invalid register" as before? See my previous post.

Happy 75th anniversary to one of the best movies ever made! Rick Blane [Bogart]: "Of all the gin joints, in all the towns, in all the world, she walks into mine."

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

JohanEkdahl wrote:

volterius wrote:

I used: LDI R25, 0x40 OR ADCSRA, R25   But the error continue.

 

Yes, bevcause the OR instruction can not handle ADCSRA, which is an I/O register. Only CPU registers (R0..R31) can be used in the OR instruction.

 

First thing you need to do when getting these errors is to look in the document AVR Instruction Set: http://www.atmel.com/Images/Atme...

 

For the OR instruction:

 

    Syntax:        Operands:                  Program Counter:
(i) OR Rd,Rr       0 ≤ d ≤ 31, 0 ≤ r ≤ 31     PC ← PC + 1

Notice the Rd and Rr notation where the "R" implies a CPU register and under "Operands" you can see which CPU registers that can be used. In the case of OR it is any of the CPU registers.

 

So you'd need to

 

1) Get the current ADCSRA value into a CPU register (R0..R31) . say Rn

2) Get the immediate value  0x40 into another register, say Rm

3) OR the value of Rm into Rn

4) Store the value in Rn into ADCSRA

 

But notice that there is also an instruction ORI that will effectively combine steps 2) ans 3) above leaving you with (sketchy, untested)

 

1) Load ADCSRA into a CPU register (Rn)

2) ORI the immediate value 0x40 into that same register

3) Store that registers value back to ADCSRA

 

 

Thank you, I wrote this and the errors have been solve:

LDI  R25, 0x40;

OR R26, R25 

STS ADCSRA, R26

 

Right now, Im going to upload the code for the simulation. 

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

JohanEkdahl wrote:

jgmdesign wrote:
What does the error say? 

 

Surely the same "Invalid register" as before? See my previous post.

Yeah, I created a new project and ran my code and got the error as well.  Then I looked at the help file and saw my blunder.  My apologies to VOLTERIUS for the wrong code, and thanks to Johan for catching it.  I am getting too used to using C nowadays it would seem.

 

Jim

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

Please Read: Code-of-Conduct

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

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

volterius wrote:
OR R26, R25
What does R26 contain? Where have you initialized it?

I believe you need:

LDS R26, ADCSRA     ; Get current value of ADCSRA into R26
ORI R26, 0x40       ; Set the ADSC bit
STS ADCSRA, R26     ; Write the modified value back to ADCSRA

Edit: correct comments

David (aka frog_jr)

Last Edited: Sun. Oct 8, 2017 - 09:26 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hello the code worked well, but at the time of simulating using proteus, the value shown on the LCD is half of the value delivered by the LM35:

I think that the solution is the multiply by 2 the value of the registers in the conversion, or failing to move those current values to a new register and then make the sum of them and that the value generated in a new record is the one that comes out of the conversion, any other solution?

 

 

CONVERSION:
LDI R17, 0x00
MOV R0, R17
MOV R1, R17
CPI R16, 0x0A
BRLO H1
H0:
SUBI R16, 0x0A
INC R1
CPI R16, 0x0A
BRSH H0
LDI R17, 0x30
OR R1, R17
H1:
MOV R0, R16
LDI R17, 0x30
OR R0, R17
RET

 

With this code I have the problem. 

Last Edited: Sun. Oct 8, 2017 - 11:50 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

volterius wrote:

hello the code worked well, but at the time of simulating using proteus, the value shown on the LCD is half of the value delivered by the LM35:

I think that the solution is the multiply by 2 the value of the registers in the conversion, or failing to move those current values to a new register and then make the sum of them and that the value generated in a new record is the one that comes out of the conversion, any other solution?

 

 

CONVERSION:
LDI R17, 0x00
MOV R0, R17
MOV R1, R17
CPI R16, 0x0A
BRLO H1
H0:
SUBI R16, 0x0A
INC R1
CPI R16, 0x0A
BRSH H0
LDI R17, 0x30
OR R1, R17
H1:
MOV R0, R16
LDI R17, 0x30
OR R0, R17
RET

 

With this code I have the problem. 

 

Right now the program is working correctly, I only change the ADMUX register with:

LDI R16, 0B11100011

STS 0x7C, R16

 

It use the Internal 2.56V Voltage Reference with external capacitor at AREF pin

 

thanks to the people who helped me. 

 

 

Last Edited: Mon. Oct 9, 2017 - 12:46 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You can use these handy macros which will autopick IN or LDS and also OUT or STS for you...must put the macro scripts at the top of your file

 

example:  OUTREG ADCSRA, r27  ;copies r27 into ADCSRA

example:  INREG   temp, ADMUX  ;read copy of ADMUX into register temp  (such as .def temp=r24)

 

; usage: InReg reg, addr
.macro InReg
    .if @1 < 0x40
        in @0, @1
    .elif ((@1 >= 0x60) && (@1 < SRAM_START))
        lds @0,@1
    .else
       .error "InReg: Invalid I/O register address"
    .endif
.endmacro 

; usage: OutReg addr, reg
.macro OutReg
    .if @0 < 0x40
        out @0, @1
    .elif ((@0 >= 0x60) && (@0 < SRAM_START))
        sts @0,@1
    .else
       .error "OutReg: Invalid I/O register address"
    .endif
.endmacro 

 

When in the dark remember-the future looks brighter than ever.

Last Edited: Mon. Oct 9, 2017 - 02:23 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

torresuao wrote:
>  I need the comments of this code because I am amateur programming in ASM. I don't understand. 

It would be a good learning exercise for you to work through the code and add your comments. I learn of lot of my asm skills from reverse engineering code.

Also, note that just about anything you need to ask has been asked before and example code provided. The AVR has been around nearly 20 years, so there’s very few new questions. Use keywords like avr asm bin to dec etc when googling.

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

Kartman wrote:
torresuao wrote:
>  I need the comments of this code because I am amateur programming in ASM. I don't understand. 

Where? No sign of either that comment or that username in the entire thread. Split?

Happy 75th anniversary to one of the best movies ever made! Rick Blane [Bogart]: "Of all the gin joints, in all the towns, in all the world, she walks into mine."

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

JohanEkdahl wrote:
 No sign of either that comment or that username in the entire thread.

There was a hijack post that now seems to have been deleted.

 

EDIT

 

Found it: http://www.avrfreaks.net/forum/s...

 

Last Edited: Thu. Oct 12, 2017 - 08:25 AM