00001 /* This file has been prepared for Doxygen automatic documentation generation.*/ 00026 #if defined(__ICCAVR__) 00027 #include <ioavr.h> 00028 #include <inavr.h> 00029 #define NOP() __no_operation() 00030 #elif defined(__GNUC__) 00031 #include <avr/io.h> 00032 #define NOP() __asm__ __volatile__ ("nop") 00033 #else 00034 //Defines for other compilers than IAR and GCC can be inserted here. 00035 #endif 00036 00037 00038 #include "TinyX61_macros.h" 00039 00040 void Error(void); 00041 00042 //Variables that will hold the values read back. 00043 volatile uint16_t temp1; 00044 volatile uint16_t temp2; 00045 volatile uint16_t temp3; 00046 unsigned char errors = 0; 00047 00054 void main(void) 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 } 00117 00118 00119 void Error(void) 00120 { 00121 errors++; 00122 }
1.4.4