Can someone help me to convert code from 90s2313 to tiny2313

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

I have to convert this code to tiny 2313 I change the first .org OC1addr
rjmp TIM_COMP1
to .org 0x004
rjmp TIM1_COMPA

And now the assembler give me error on portd commands
I check the datasheet and it have the same name with 2313
Also I read the doc4298 from atmel and didnt find anything about that
Thanks for any help

Attachment(s): 

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

The very first thing you need to do is to change .include "2313def.inc" to .include "tn2313def.inc"

...sorry I had to do something else :)

The second thing you need to do is to read AVR091: Replacing AT90S2313 by ATtiny2313.

Then start doing all the necessary changes to the code.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

Last Edited: Sun. May 2, 2010 - 09:54 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The very second thing is to find the include file so you can remove the errors you get.
C:\Program Files\Atmel\AVR Tools\AvrAssembler2\Appnotes

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

Quote:
to find the include file
?? The assembler does find it for you. :) (without the path)

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

I have change the include before I make this post.
I have read the document 091 but about portd didnt say anything.
I except to have problem in interrupts or something like this.
I will read again of-course more carefully.
I didn't understand what to change in assember2 tn2313def.inc file

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

Quote:

I have change the include before I make this post.

??? The code you posted has "2313def... in it.

Why would you change from a named vector address to a hard-coded one?

Show the code you are >>really<< using. Preferably, a short complete test program. Tell exactly the errors you are getting. Tell which toolchain and version you are using.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

Quote:
I didn't understand what to change in assember2 tn2313def.inc file
The Tiny 2313 MUST use the tn2313def.in as it has different interrupts, pin definitions etc. for it whether you are using assembler version 1 (not recomended) or assembler version 2.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Quote:
I have read the document 091 but about portd didnt say anything.
Then PORTD didn't change.
Quote:
I didn't understand what to change in assember2 tn2313def.inc file
You don't change anything in the .inc file, you simply specify it.
Quote:
I except to have problem in interrupts or something like this.
What problems do you have with the interrupts?

Regards,
Steve A.

The Board helps those that help themselves.

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

I change from avr studio the assembler option to the folder avrassembler2/appnotes and build with no errors
This is the only changes I have made
from:
.org OC1addr
rjmp TIM_COMP1 ;timer1 compare handler
.org OVF1addr
rjmp TIM_OVF1 ;timer1 overflow handler
.org OVF0addr
rjmp TIM_OVF0 ;timer0 overflow handler

to:
.org 0x0004
rjmp TIM_COMP1 ;timer1 compare handler
.org 0x0005
rjmp TIM_OVF1 ;timer1 overflow handler
.org 0x0006
rjmp TIM_OVF0 ;timer0 overflow handler

ofcourse and the inlcude file

I use avr assembler 1 I dont know the difference from 1 to 2 I have to read about that

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

Quote:

from:
.org OC1addr

Quote:

Why would you change from a named vector address to a hard-coded one?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

You mean to name the address of oc1addr with new tiny name and not numbers?

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

Quote:
I use avr assembler 1 I dont know the difference from 1 to 2
assembler 1 is the OLDER assembler and does NOT support newer chips. So use assembler 2 whenever you can even if it means some small changes to older projects.

It should not make much difference with this project as assembler 1 also supports the Tiny 2313. HOWEVER do NOT specify the path for the include file as each assembler will find tham in their own paths. ie the include files are not necessarily the same for assembler 1 and assembler 2.

edit also look at the additional interrupt vectors in the T2313. What Lee is saying that you should not hard code the address of the ISR but rather use it's name.

Reset and Interrupt vectors 90s23133
;

.cseg

;$000
	rjmp	RESET		;Reset Handler. To beginning of program 
;$001
	rjmp	EXT_INT0	;IRQ 0 Handler
;$002
	rjmp	EXT_INT1	;IRQ 1 Handler
;$003
	rjmp	TIM1_CAPT	;Timer 1 capture Handler 
;$004
	rjmp	TIM1_COMP	;Timer 1 compare
;$005
 	rjmp	TIM1_OVF	;Timer 1 overflow Handler
;$006
	rjmp	TIM0_OVF	;Timer 0 overflow Handler
;$007
	rjmp	UART_RXC	;Uart RX complete Handler
;$008	
	rjmp	UART_DRE	;Uart data register empty
;$009	
	rjmp	UART_TXC	;Uart TX complete Handler
;$00A
	rjmp	ANA_COMP	;Analog comparator Handler
;Reset and Interrupt vectors Tiny2313
;
.cseg

;0x0000 
	rjmp 	RESET 				;Reset Handler
;0x0001 
	rjmp 	ISR_INT0 			;External Interrupt0 Handler
;0x0002 
	rjmp 	ISR_INT1 			;External Interrupt1 Handler
;0x0003 
	rjmp 	ISR_TIM1_CAPT 		;Timer1 Capture Handler
;0x0004 
	rjmp 	ISR_TIM1_COMPA 		;Timer1 CompareA Handler
;0x0005
	rjmp 	ISR_TIM1_OVF 		;Timer1 Overflow Handler
;0x0006
	rjmp 	ISR_TIM0_OVF 		;Timer0 Overflow Handler
;0x0007
	rjmp 	ISR_USART0_RXC 		;USART0 RX Complete Handler
;0x0008 
	rjmp 	ISR_USART0_DRE 		;USART0,UDR Empty Handler
;0x0009
	rjmp 	ISR_USART0_TXC 		;USART0 TX Complete Handler
;0x000A 
	rjmp 	ISR_ANA_COMP 		;Analog Comparator Handler
;0x000B 
	rjmp 	ISR_PCINT 			;Pin Change Interrupt
;0x000C 
	rjmp 	ISR_TIMER1_COMPB 	;Timer1 Compare B Handler
;0x000D 
	rjmp 	ISR_TIMER0_COMPA 	;Timer0 Compare A Handler
;0x000E 
	rjmp 	ISR_TIMER0_COMPB 	;Timer0 Compare B Handler
;0x000F 
	rjmp 	ISR_USI_START 		;Usi Start Handler
;0x0010 
	rjmp 	ISR_USI_OVERFLOW 	;USI Overflow Handler
;0x0011 
	rjmp 	ISR_EE_READY 		;EEPROM Ready Handler
;0x0012 
	rjmp 	ISR_WDT_OVERFLOW 	;Watchdog Overflow Handler

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Most 90s2313 programs will run just fine with a tiny2313 chip. Obviously the reverse is not true. And the fuses are very different.

Just assembling with

.include "tn2313def.inc"

creates no errors. But there are several warnings because you appear to be using the index registers for general purposes.

As far as I know the index registers have always existed on AVRs. So it seems foolish to waste them!

David.

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

Quote:
?? The assembler does find it for you. Smile (without the path)

Very true.
Will it also change any errors in code that might turn up with the new include file?

Maybe I wasn't clear in my post.
If there are differences with respect to I/O register names, Interrupt vectors and what not, it's easy to find the new ones to be used looking at that file.
Of course you can get that info from datasheet but include file have it presented in a easy to find way.
Of course include files are read only.
Clear enough?

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

petros047 wrote:
I have to convert this code to tiny 2313 I change the first

.org OC1addr
rjmp TIM_COMP1
to .org 0x004
rjmp TIM1_COMPA

should be :

.org OC1Aaddr

petros047 wrote:

And now the assembler give me error on portd commands

in the tn2313def.inc file (the one I have), there is no such thing as PD2, PD3, etc.

use this format:

cbi PORTD,1 or cbi DDRD,1

in your code you can define each bit. For example:

.equ TXPIN = 1    ;TX output pin
.equ RXPIN = 0    ;RX input pin 

then the code will look like this:

cbi PORTD,TXPIN or sbi DDRD,TXPIN

you will not get warnings if you refrain from using the upper registers r26,r27,r28,r29,r30,r31 because they are already defined in the tn2313def.inc file as XL,XH,YL,YH,ZL,ZH. This does not mean you can not use these registers, just don't try to rename them.

look in the zip file for the changes I made. I didn't look at the timer code.

hope it helps.

Attachment(s): 

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

Quote:
in the tn2313def.inc file (the one I have), there is no such thing as PD2, PD3, etc.
One more reason to use assembler 2? :)

; ***** PORTD ************************
; PORTD - Data Register, Port D
.equ	PORTD0	= 0	; 
.equ	PD0	= 0	; For compatibility
.equ	PORTD1	= 1	; 
.equ	PD1	= 1	; For compatibility
.equ	PORTD2	= 2	; 
.equ	PD2	= 2	; For compatibility
.equ	PORTD3	= 3	; 
.equ	PD3	= 3	; For compatibility
.equ	PORTD4	= 4	; 
.equ	PD4	= 4	; For compatibility
.equ	PORTD5	= 5	; 
.equ	PD5	= 5	; For compatibility
.equ	PORTD6	= 6	; 
.equ	PD6	= 6	; For compatibility

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

I have to say that all you guys are very kind and give me so much help . This forum is the best forum with serious support.
Yes I finally convert the code.
Thank you all for the support continue the good job.
Definitely the best forum.