need some nice tutorial on Atmaga128 16bit timer/counter and use of ICP

Started by Mazhar Mazhar October 7, 2009
hi
i am a newbee in microcontroller world and need some good tutorials about timers/ counters and use of Input capture pin, i found few on sourceforge site but i need to have more practical approach and information. can any body provide me such guidlines, so that i could start working. right now i have developed my own development board housing Atmega128, so it would be great that if i found information related to this controller thanks.
regards




Hi all
any body out there knows where can I get some tutorials Atmega644 about timers/ counters and use of Input capture pin and how to use TW, i found AVR studio i need to have more practical approach and information. can any body provide me such guidlines too.

With kind regards.

C and assembly code samples for corresponding peripherals
(UART,Timers/Counters etc.) of ATmega644 are given in data sheet of
Atmega644.
However,tutorials on AVR in general may be found at : www.avrfreaks.com

Use Image craft compiler's code wizard (compiler ver 7.14,7.19 or
above) and simulate in Proteus VSM for learning AVR fast.

regards
m.yasir

On 07/10/2009, abdel_namiq wrote:
> Hi all
> any body out there knows where can I get some tutorials Atmega644 about
> timers/ counters and use of Input capture pin and how to use TW, i found AVR
> studio i need to have more practical approach and information. can any body
> provide me such guidlines too.
>
> With kind regards.
--
regards
m.yasir
Thanks Muhammed

Have you got any assembly cod to share just for learning purpose if you don't mind I haven't seen any code samples on these topics on the date sheet except few simple instructions on how to use registers egg add, adiw,...

kind regards,

Abdel.

--- In a..., Muhammad Yasir wrote:
>
> C and assembly code samples for corresponding peripherals
> (UART,Timers/Counters etc.) of ATmega644 are given in data sheet of
> Atmega644.
> However,tutorials on AVR in general may be found at : www.avrfreaks.com
>
> Use Image craft compiler's code wizard (compiler ver 7.14,7.19 or
> above) and simulate in Proteus VSM for learning AVR fast.
>
> regards
> m.yasir
>
> On 07/10/2009, abdel_namiq wrote:
> >
> >
> > Hi all
> > any body out there knows where can I get some tutorials Atmega644 about
> > timers/ counters and use of Input capture pin and how to use TW, i found AVR
> > studio i need to have more practical approach and information. can any body
> > provide me such guidlines too.
> >
> > With kind regards.
> >
> >
> --
> regards
> m.yasir
>

yes you are right,i haven't either seen any code samples on use of TWI/I2C
interface in data sheet of ATmega644.A few weeks back i have also been
working on it,i.e. I2C.I had to interface Atmega644/644P with I2C based
serial EEPROM AT24C512.ATmega664P serving as master while serial memory
serves as slave.

I think code for TWI is not given in data sheet of ATmega644.

I have got code only for interafacing AT24C512 serial memory with Atmega644
through I2C interface.I had to work out my own code in C.
regards
m.yasir
On 08/10/2009, abdel_namiq wrote:
> Thanks Muhammed
>
> Have you got any assembly cod to share just for learning purpose if you
> don't mind I haven't seen any code samples on these topics on the date sheet
> except few simple instructions on how to use registers egg add, adiw,...
>
> kind regards,
>
> Abdel.
>
> --- In a... , Muhammad Yasir
> wrote:
> >
> > C and assembly code samples for corresponding peripherals
> > (UART,Timers/Counters etc.) of ATmega644 are given in data sheet of
> > Atmega644.
> > However,tutorials on AVR in general may be found at : www.avrfreaks.com
> >
> > Use Image craft compiler's code wizard (compiler ver 7.14,7.19 or
> > above) and simulate in Proteus VSM for learning AVR fast.
> >
> > regards
> > m.yasir
> >
> > On 07/10/2009, abdel_namiq >
> wrote:
> > >
> > >
> > > Hi all
> > > any body out there knows where can I get some tutorials Atmega644 about
> > > timers/ counters and use of Input capture pin and how to use TW, i
> found AVR
> > > studio i need to have more practical approach and information. can any
> body
> > > provide me such guidlines too.
> > >
> > > With kind regards.
> > >
> > >
> >
> >
> > --
> > regards
> > m.yasir
> >
>

--
regards
m.yasir


Hi muhammed,

Thanks again for the replay, I find it very frustrating that I can't use any of the interesting properties of this device any idea how to set TIMSK1 for instance to enable timer1 interrupt because i used it fine with AT90S2313 but with Atmeg644 the assembler doesn't recognize it even when I INCLUDE "m644def.inc" I noticed using AVR Studio that the address for it so as TWI and many other i/o are na not accessible I assume for some reason but it must be some ways of using them I thing some code will help...

I managed to write few simple branching using timer0, some of 32 reg and the ports

but could not find TIMSK0 to use it as interrupt I just used the timer to count and when it reach a given value I branch...that's the only solution I can think of to turn an o/p on&of as square wave with variable frequency for egg....

kind regards

Abdel.
--- In a..., Muhammad Yasir wrote:
>
> yes you are right,i haven't either seen any code samples on use of TWI/I2C
> interface in data sheet of ATmega644.A few weeks back i have also been
> working on it,i.e. I2C.I had to interface Atmega644/644P with I2C based
> serial EEPROM AT24C512.ATmega664P serving as master while serial memory
> serves as slave.
>
> I think code for TWI is not given in data sheet of ATmega644.
>
> I have got code only for interafacing AT24C512 serial memory with Atmega644
> through I2C interface.I had to work out my own code in C.
> regards
> m.yasir
> On 08/10/2009, abdel_namiq wrote:
> >
> >
> >
> >
> > Thanks Muhammed
> >
> > Have you got any assembly cod to share just for learning purpose if you
> > don't mind I haven't seen any code samples on these topics on the date sheet
> > except few simple instructions on how to use registers egg add, adiw,...
> >
> > kind regards,
> >
> > Abdel.
> >
> > --- In a... , Muhammad Yasir
> > wrote:
> > >
> > > C and assembly code samples for corresponding peripherals
> > > (UART,Timers/Counters etc.) of ATmega644 are given in data sheet of
> > > Atmega644.
> > > However,tutorials on AVR in general may be found at : www.avrfreaks.com
> > >
> > > Use Image craft compiler's code wizard (compiler ver 7.14,7.19 or
> > > above) and simulate in Proteus VSM for learning AVR fast.
> > >
> > > regards
> > > m.yasir
> > >
> > > On 07/10/2009, abdel_namiq >
> > wrote:
> > > >
> > > >
> > > > Hi all
> > > > any body out there knows where can I get some tutorials Atmega644 about
> > > > timers/ counters and use of Input capture pin and how to use TW, i
> > found AVR
> > > > studio i need to have more practical approach and information. can any
> > body
> > > > provide me such guidlines too.
> > > >
> > > > With kind regards.
> > > >
> > > >
> > >
> > >
> > > --
> > > regards
> > > m.yasir
> > >
> >
> >
> > --
> regards
> m.yasir
>
>

Hi,

The problem you may be having is how you try to use these registers, the register TIMSK1 is "memory mapped" as opposed to being in the I/O space, this means that instructions such as i/out etc will not work and will throw up errors. If you read the atmel instruction set direct addressing overcomes this problem note below

Lets say we want to set the Timer1 overflow bit,,

1) Read he TIMSK register = lds r2,$TIMSK1
2) Set the required bit = sbi r2,TOIE1
3) Load the value into the register = sts $TIMSK1,r2
Try this and see if the compiler has a problem with this.

Regards

--- In a..., abdel_namiq wrote:
> Hi muhammed,
>
> Thanks again for the replay, I find it very frustrating that I can't use any of the interesting properties of this device any idea how to set TIMSK1 for instance to enable timer1 interrupt because i used it fine with AT90S2313 but with Atmeg644 the assembler doesn't recognize it even when I INCLUDE "m644def.inc" I noticed using AVR Studio that the address for it so as TWI and many other i/o are na not accessible I assume for some reason but it must be some ways of using them I thing some code will help...
>
> I managed to write few simple branching using timer0, some of 32 reg and the ports
>
> but could not find TIMSK0 to use it as interrupt I just used the timer to count and when it reach a given value I branch...that's the only solution I can think of to turn an o/p on&of as square wave with variable frequency for egg....
>
>
> kind regards
>
> Abdel.
> --- In a..., Muhammad Yasir wrote:
> >
> > yes you are right,i haven't either seen any code samples on use of TWI/I2C
> > interface in data sheet of ATmega644.A few weeks back i have also been
> > working on it,i.e. I2C.I had to interface Atmega644/644P with I2C based
> > serial EEPROM AT24C512.ATmega664P serving as master while serial memory
> > serves as slave.
> >
> > I think code for TWI is not given in data sheet of ATmega644.
> >
> > I have got code only for interafacing AT24C512 serial memory with Atmega644
> > through I2C interface.I had to work out my own code in C.
> >
> >
> > regards
> > m.yasir
> >
> >
> > On 08/10/2009, abdel_namiq wrote:
> > >
> > >
> > >
> > >
> > > Thanks Muhammed
> > >
> > > Have you got any assembly cod to share just for learning purpose if you
> > > don't mind I haven't seen any code samples on these topics on the date sheet
> > > except few simple instructions on how to use registers egg add, adiw,...
> > >
> > > kind regards,
> > >
> > > Abdel.
> > >
> > > --- In a... , Muhammad Yasir
> > > wrote:
> > > >
> > > > C and assembly code samples for corresponding peripherals
> > > > (UART,Timers/Counters etc.) of ATmega644 are given in data sheet of
> > > > Atmega644.
> > > > However,tutorials on AVR in general may be found at : www.avrfreaks.com
> > > >
> > > > Use Image craft compiler's code wizard (compiler ver 7.14,7.19 or
> > > > above) and simulate in Proteus VSM for learning AVR fast.
> > > >
> > > > regards
> > > > m.yasir
> > > >
> > > > On 07/10/2009, abdel_namiq >
> > > wrote:
> > > > >
> > > > >
> > > > > Hi all
> > > > > any body out there knows where can I get some tutorials Atmega644 about
> > > > > timers/ counters and use of Input capture pin and how to use TW, i
> > > found AVR
> > > > > studio i need to have more practical approach and information. can any
> > > body
> > > > > provide me such guidlines too.
> > > > >
> > > > > With kind regards.
> > > > >
> > > > >
> > > >
> > > >
> > > > --
> > > > regards
> > > > m.yasir
> > > >
> > >
> > >
> > >
> >
> >
> >
> > --
> > regards
> > m.yasir
> >
> >
> >
>