Main Page | File List | Globals

example.c File Reference


Detailed Description

Example application for application note AVR073.

This code shows how to use the macros included with AVR073.

Application note:
AVR073: Accessing 10 and 16 bit registers in ATtinyX61
Documentation
For comprehensive code documentation, supported compilers, compiler settings and supported devices see readme.html
Author:
Atmel Corporation: http://www.atmel.com
Support email: avr@atmel.com
Name
RELEASE_1_0
Revision
1.2
RCSfile
example.c,v
Date
2006/04/25 09:21:18

Definition in file example.c.

#include "TinyX61_macros.h"

Include dependency graph for example.c:

Go to the source code of this file.

Functions

void Error (void)
void main (void)
 Program start.

Variables

unsigned char errors = 0
volatile uint16_t temp1
volatile uint16_t temp2
volatile uint16_t temp3


Function Documentation

void Error void   ) 
 

Definition at line 119 of file example.c.

References errors.

Referenced by main().

00120 {
00121   errors++;
00122 }

void main void   ) 
 

Program start.

This example program tests all macros. When the program reaches the eternal 'for' loop, the 'errors' variable can be inspected to see the number of errors that occured.

Definition at line 54 of file example.c.

References Error(), TC0_READ_16_BIT_OCR0AB, TC0_READ_16_BIT_OCR0AB_INT_SAFE, TC0_READ_TCNT0, TC0_READ_TCNT0_INT_SAFE, TC0_WRITE_16_BIT_OCR0AB, TC0_WRITE_16_BIT_OCR0AB_INT_SAFE, TC0_WRITE_TCNT0, TC0_WRITE_TCNT0_INT_SAFE, TC1_READ_10_BIT_REGISTER, TC1_READ_10_BIT_REGISTER_INT_SAFE, TC1_SET_ALL_COMPARE_VALUES, TC1_WRITE_10_BIT_REGISTER, TC1_WRITE_10_BIT_REGISTER_INT_SAFE, temp1, temp2, and temp3.

00055 {
00056   TC0_WRITE_TCNT0(0x55aa);
00057   TC0_READ_TCNT0(temp1);
00058   if (temp1 != 0x55aa)
00059   {
00060     Error();
00061   }
00062 
00063   TC0_WRITE_TCNT0_INT_SAFE(0xaa55);
00064   TC0_READ_TCNT0_INT_SAFE(temp1);
00065   if (temp1 != 0xaa55)
00066   {
00067     Error();
00068   }
00069 
00070   TC0_WRITE_16_BIT_OCR0AB(0x55aa);
00071   TC0_READ_16_BIT_OCR0AB(temp1);
00072   if (temp1 != 0x55aa)
00073   {
00074     Error();
00075   }
00076 
00077   TC0_WRITE_16_BIT_OCR0AB_INT_SAFE(0xaa55);
00078   TC0_READ_16_BIT_OCR0AB_INT_SAFE(temp1);
00079   if (temp1 != 0xaa55)
00080   {
00081     Error();
00082   }
00083 
00084   TC1_WRITE_10_BIT_REGISTER(TCNT1, 0x03ff);
00085   //Due to synchronization issues, wait for 3 clock cycles. See device data
00086   //sheet for details.
00087   NOP();
00088   NOP();
00089   NOP();
00090   TC1_READ_10_BIT_REGISTER(TCNT1, temp1);
00091   if (temp1 != 0x03ff)
00092   {
00093     Error();
00094   }
00095 
00096   TC1_WRITE_10_BIT_REGISTER_INT_SAFE(OCR1A, 0x0255);
00097   TC1_READ_10_BIT_REGISTER_INT_SAFE(OCR1A, temp1);
00098   if (temp1 != 0x0255)
00099   {
00100     Error();
00101   }
00102 
00103   TC1_SET_ALL_COMPARE_VALUES(0x03ff);
00104   TC1_READ_10_BIT_REGISTER(OCR1A, temp1);
00105   TC1_READ_10_BIT_REGISTER(OCR1B, temp2);
00106   TC1_READ_10_BIT_REGISTER(OCR1D, temp3);
00107   if ( (temp1 != 0x03ff) || (temp2 != 0x3ff) || (temp3 != 0x3ff))
00108   {
00109     Error();
00110   }
00111 
00112   for(;;)
00113   {
00114 
00115   }
00116 }

Here is the call graph for this function:


Variable Documentation

unsigned char errors = 0
 

Definition at line 46 of file example.c.

Referenced by Error().

volatile uint16_t temp1
 

Definition at line 43 of file example.c.

Referenced by main().

volatile uint16_t temp2
 

Definition at line 44 of file example.c.

Referenced by main().

volatile uint16_t temp3
 

Definition at line 45 of file example.c.

Referenced by main().


Generated on Tue Apr 25 12:43:00 2006 for AVR073: Accessing 10 and 16 bit registers in ATtinyX61 by  doxygen 1.4.4