Tiny13 code ported to tiny 2313

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

Hello everyone. Could anybody help me, please  to transfer a third party code (http://jumptuck.com/2010/08/01/g...) from Tiny13  to Tiny2313 ?

I am confused with the equivalence of timers, only.

Last Edited: Wed. Nov 6, 2019 - 12:32 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It looks as if you only have to change:

//  TIMSK0 |= 1<<TOIE0;     //enable timer overflow interrupt
  TIMSK |= 1<<TOIE0;     //enable timer overflow interrupt
...
//ISR(TIM0_OVF_vect)           // every 10ms
ISR(TIMER0_OVF_vect)           // every 10ms

Untested.

 

I suggest that you use the same PORT pins e.g. for LED, Button, ...

 

David.

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

Neat project, I assume you already have the T2313's or else you could just use a T13 as in the project, Note a T25 would also work here.

Let us know if you get it working.

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

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

It does not working... I forced one output but it ignored it. I am wondering if DDRB is correctly configured. 

 

PB1 , PB3 as input

 

PB2, PB4 as output

 

I am not familiar with the specific expression in this code. Its a good idea to just load a HEX or Binary value to the DDR B register ?

 

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

I used the Simulator in AS7.0 for Tiny2313.   The program should work fine.

 

Your PB1, PB2, PB3, PB4 seem fine.

 

With default fuses from the Factory:

Note that the Tiny13 expects to run on its internal 9.6MHz RC divided by 8 = 1.2MHz

The Tiny2313 will run on Internal 8MHz RC div8 = 1.0MHz

 

Alter F_CPU in the source code to 1000000

 

Obviously I have not run on hardware.

I suggest that you check your wiring.

 

David.

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

David,

 

Why you wrote that XTAL is 9.6 MHz  and finaly with the divider will be 1 MHz ? This means that F_CPU in the source code to 1000000 is wrong or in any way , wiil be ignored ?

 

 

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

He's talking about this:

#define F_CPU 1200000

They are using that for the t13 because it's core clock is 9.6MHz but there's a default /8 (CLKDIV8) of that so 9.6/8 = 1.2

 

As the t2313 defaults to 1MHz (8MHz / 8 = 1MHz) then it needs to be:

#define F_CPU 1000000

 

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

But regardless the clock, the project still not working at all. I tried to test general functionality , so  I added the following. DDRD =0xF5 , an in main function I added:

 

LED_PORT |= 1<<LED0;

delay_ms(1000)!

LED_PORT &=~(1<<LED0);

 

The problem is that Led is always on after compilation. I tried also to disable interrupts by this //TIMSK |= 1<<TOIE0;  , but still led remain on. Any ideas ?

 

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

I will try it on real hardware.  And let you know.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
Sorry David but i would not like to bother you...   

 

 

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

The program builds, programs,  LED flashes.

 

OTOH,  I can't get the door to unlock with "1234"

 

David.

 

Edit.   Woo-Hoo.   It does work.

Last Edited: Thu. Nov 7, 2019 - 02:06 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Even worse ! Although that I have the same version of AVR studio in my desktop and laptop and I copied the project from the first to the second, my laptop AVR studio refuses to compile the project !

 

Error message is :

 

------ Rebuild All started: Project: Jumptuck, Configuration: Debug AVR ------
Build started.
Project "Jumptuck.cproj" (ReBuild target(s)):
Target "PreBuildEvent" skipped, due to false condition; ('$(PreBuildEvent)'!='') was evaluated as (''!='').
Target "CoreRebuild" in file "C:\Program Files (x86)\Atmel\AVR Studio 5.1\Vs\Compiler.targets" from project "C:\Users\user\Documents\AVRStudio 5.1\Jumptuck\Jumptuck\Jumptuck.cproj" (target "ReBuild" depends on it):
    Task "RunCompilerTask"
        C:\Program Files (x86)\Atmel\AVR Studio 5.1\make\make.exe clean all
        rm -rf  Jumptuck.o Jumptuck.d  
        rm -rf "Jumptuck.hex" "Jumptuck.lss" "Jumptuck.eep" "Jumptuck.map"
        process_begin: CreateProcess(C:\Users\user\AppData\Local\Temp\make4464-1.bat, C:\Users\user\AppData\Local\Temp\make4464-1.bat, ...) failed.
        make (e=5): Access is denied.
        make: *** [clean] Error 5
    Done executing task "RunCompilerTask" -- FAILED.
Done building target "CoreRebuild" in project "Jumptuck.cproj" -- FAILED.
Done building project "Jumptuck.cproj" -- FAILED.

Build FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

 

 

 

 

WHY ???

what is    "make (e=5): Access is denied." 

Any Ideas ?

 

On the other hand, in desktop, althogh it compiles without problems, it still does not working !

David, If you still have the .c that worked, could you please upload it ?  

 

PS Please don't blame me for using studio 5.1 instead of 7.x. I used it because it is lighter ...

Last Edited: Thu. Nov 7, 2019 - 07:37 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have attached the AS7.0 project.    You only need the "main.c" file.

 

Note that LED and Relay are active-high.   Seems un-intuitive to me.

 

David.

Attachment(s): 

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

bnsavr wrote:
Any Ideas ?
Guesses :

  • account type (local administrator, user)
  • UAC

bnsavr wrote:
I used it because it is lighter ...
Lighter in mass storage by selecting Atmel Studio parts during its installation.

Lighter in CPU and RAM and IO (video) utilization? concur

Atmel Studio 6 consumes an additional 1GB of mass storage.

 


Installation | Atmel Studio 7

[bottom] [mid-page]

  • Make sure your user has local administrator privileges

...

Once finished, the installer displays an option to Start Atmel Studio after completion. If you choose to open, then note that Atmel Studio will launch with administrative privileges, since the installer was either launched as administrator or with elevated privileges.

...

Installation and Updates | Atmel Studio 7

...

Video: Installation and Updates [3m21s]

...

UAC - User Account Control

Guided Help: Adjust User Account Control settings in Windows 7 and Windows 8

User Account Control (Windows 10) | Microsoft Docs

AVR and SAM Downloads Archive | Microchip Technology

 

"Dare to be naïve." - Buckminster Fuller

Last Edited: Thu. Nov 7, 2019 - 09:07 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
  • UAC is in lower position.
  • Account has administration privileges.
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have made the suggestions of gchapman and compiler works *for the time being * in my latop too.

 

Same concerning the software although it does not accept the initial code sequence as valid.

 

David, did you program the EEPROM or not ?  And by the way, how to configure AVR studio to export also EEPROM file ?

 

 

 

Last Edited: Fri. Nov 8, 2019 - 12:19 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The creation of the EEPROM init (hex) file already happens because of:

unsigned char EEMEM code1 = 1;
unsigned char EEMEM code2 = 2;
unsigned char EEMEM code3 = 3;
unsigned char EEMEM code4 = 4;

When the whole program is built there are THREE output files. First the linker creates a file with everything in it called <projname>.ELF, that file contains both the code and the EEPROM values (1,2,3,4). But it holds the data in different sections. The stuff that needs to go into the flash are in sections called ".text" and ".data" and the stuff that needs to go into the EEPROM is in a section called ".eeprom". So the final steps of the build run the program called avr-objcopy twice. The first one extracts from the .ELF file the .text+.data sections to create <projname>.HEX which is an Intel Hex file. Then the second run of avr-objcopy extracts (if there is anything in ".eeprom") the data from .eeprom and writes it into a file called <projname>.EEP, despite the file extension this is ALSO an Intel Hex file. You can see this happening in a normal build output such as this:

		Building target: test.elf
		Invoking: AVR8/GNU Linker : 5.4.0
		"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-g++.exe" -o test.elf  main.o   -Wl,-Map="test.map" -Wl,--start-group -Wl,-lm  -Wl,--end-group -Wl,--gc-sections -mrelax -mmcu=atmega2561 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.3.300\gcc\dev\atmega2561" -Wl,-print-gc-sections -Wl,-section-start=.fram=0x10000000  
		Finished building target: test.elf
		"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -O ihex -R .eeprom -R .fuse -R .lock -R .signature -R .user_signatures  "test.elf" "test.hex"
		"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -j .eeprom  --set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0  --no-change-warnings -O ihex "test.elf" "test.eep" || exit 0

That creates ELF then from ELF it creates HEX and then EEP.

 

You then use your ISP programmer to program both files into the AVR. The <projname>.HEX is programmed into the flash and the <projname>.EEP is programmed into the EEPROM.

Last Edited: Fri. Nov 8, 2019 - 01:04 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In AS7.0 Project->Properties->Tool:

select Programmer e.g. ATMEL-ICE, STK500, ...

select Programmer settings i.e. [Erase entire chip] and uncheck [Preserve EEPROM]

 

This ensures that the EEPROM gets programmed with your EEMEM values.

 

If you are unsure about programmers, settings, ... tell us what hardware you have.   And whether you use AS7.0,  AS6.2, ....

 

David.

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

As far as this topic is concerned, I use most of the times ISP programmer from e-bay and Extreme burner AVR. I am not a novice to micro controllers, so actually it is ok for me to exclude EEPROM during Flash programming.

But I have to thank you again,  because you (All all of You in that forum) help us very much.

On the other hand I faced difficulties all the time that I decide to use AVR studio with C language, instead using it with assembly. I can not understand how to configure an use correctly WINAVR / GCC and I do not really understand why this happens. In the past I used CC5x compiler within Microchip studio mplab and it was ok for me. If I isolate the problems with WINAVR / GCC, AVR studio seems to be very good IDE.

Last Edited: Sat. Nov 9, 2019 - 02:28 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Clawson thank You for Your help ! One thing that I can not so clear in, is the following. When I program flash , it is necessary or not to write also the relevant .eep file, or when the the program start , will write the 1234 sequence to  EEPROM so I can omit that step ? Probably I must not omit it only when it is not mentioned in main program that initial sequence. Is that correct ?

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

AS4.xx worked pretty well

AS7.0 works well

As with any complex IDE,  ticking the wrong boxes can make life difficult.

 

I would never trust Extreme Burner software.

I know nothing about CC5x compiler.

MPLABX works well for building and managing projects.

MPLABX is pretty horrible for any "hardware debugging"

 

Your GarageLock project is fairly simple.   You just compile and go.   But you need to check that EEPROM was programmed i.e. AS7.0 is not being "too clever"

 

David.

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

david.prentice wrote:
I would never trust Extreme Burner software.

EB works fine for the AVRs it supports and is an easy gui programmer for the usbasp.

I do agree with david, use either AS4.19 or AS7(latest), the others are not worth messing with as far as AS is concerned.

No experience yet with mplab except with pics.

The code above compiled with changes in interrupts/eeprom as needed in Imagecraft C as well for T13, T2313 and T25.

Jim

 

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

Last Edited: Sun. Nov 10, 2019 - 07:16 PM