⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.lst

📁 atmel at91SAM7a3 ADC sample
💻 LST
📖 第 1 页 / 共 5 页
字号:
   1              		.code	16   2              		.file	"main.c"  10              	.Ltext0:  11              		.section	.text.wait,"ax",%progbits  12              		.align	2  13              		.code 16  14              		.thumb_func  16              	wait:  17              	.LFB393:  18              		.file 1 "main.c"   1:main.c        **** //*----------------------------------------------------------------------------
   2:main.c        **** //* AT91SAM7S example application "gamma" (SWI, stdio, remapping...)
   3:main.c        **** //*----------------------------------------------------------------------------
   4:main.c        **** //* The software is delivered "AS IS" without warranty or condition of any
   5:main.c        **** //* kind, either express, implied or statutory. This includes without
   6:main.c        **** //* limitation any warranty or condition with respect to merchantability or
   7:main.c        **** //* fitness for any particular purpose, or against the infringements of
   8:main.c        **** //* intellectual property rights of others.
   9:main.c        **** //*----------------------------------------------------------------------------
  10:main.c        **** //* 
  11:main.c        **** //* by Martin Thomas, Kaiserslautern, Germany
  12:main.c        **** //*    http://www.siwawi.arubi.uni-kl.de/avr_projects
  13:main.c        **** //*
  14:main.c        **** //* partly based on free code from Atmel Rousset, Keil/ARM and others
  15:main.c        **** //*
  16:main.c        **** //*----------------------------------------------------------------------------
  17:main.c        **** 
  18:main.c        **** /* 
  19:main.c        ****    20070211 : defining CUSTOM_PCB disables switches
  20:main.c        **** 			  -mods made to makefile, and renaming of files for SAM7A3
  21:main.c        ****    20060902 : PIT ISR-Handler in RAM (__ramfunc),
  22:main.c        **** */
  23:main.c        **** 
  24:main.c        **** #include <stdint.h>
  25:main.c        **** #include <stdio.h>
  26:main.c        **** 
  27:main.c        **** #include "Board.h"
  28:main.c        **** #include "dbgu.h"
  29:main.c        **** #include "swi.h"
  30:main.c        **** 
  31:main.c        **** /* Global variables */
  32:main.c        **** #define SPEED 		(MCKKHz/10)
  33:main.c        **** const int led_mask[8]= {LED1, LED2, LED3};
  34:main.c        **** 
  35:main.c        **** unsigned int LedSpeed = SPEED *50 ;
  36:main.c        **** 
  37:main.c        **** 
  38:main.c        **** 
  39:main.c        **** #define	SAMPLE			16
  40:main.c        **** 
  41:main.c        **** 
  42:main.c        **** #define RTTC_INTERRUPT_LEVEL   0
  43:main.c        **** #define PIV_200_MS             600000  //* 200 ms for 48 MHz
  44:main.c        **** 
  45:main.c        **** #define SWDEBOUNCE 2
  46:main.c        **** volatile int sw1cnt, sw2cnt;
  47:main.c        **** volatile unsigned long systick;
  48:main.c        **** 
  49:main.c        **** 
  50:main.c        **** 
  51:main.c        **** #define PWM_PRESCALE 2
  52:main.c        **** 
  53:main.c        **** // 5khz period for channel 0
  54:main.c        **** #define PERIOD_CH0 1/50000
  55:main.c        **** 
  56:main.c        **** // 25% duty cycle for CH0
  57:main.c        **** #define DUTY_CH0 1/4
  58:main.c        **** 
  59:main.c        **** // 10 kHz period for channel 1
  60:main.c        **** #define PERIOD_CH1 1/10000
  61:main.c        **** 
  62:main.c        **** // 60% duty cycle for CH1
  63:main.c        **** #define DUTY_CH1 6/10 
  64:main.c        **** 
  65:main.c        **** //*----------------------------------------------------------------------------
  66:main.c        **** //* Function Name       : Periodic_Interval_Timer_handler
  67:main.c        **** //* Object              : C handler interrupt function called by the interrupts
  68:main.c        **** //*                       assembling routine
  69:main.c        **** //*----------------------------------------------------------------------------
  70:main.c        **** __ramfunc void Periodic_Interval_Timer_handler(void) 
  71:main.c        **** {
  72:main.c        **** 	volatile uint32_t status;
  73:main.c        **** 	//volatile uint32_t ledOnCount;
  74:main.c        **** 	
  75:main.c        **** 	// Interrupt Acknowledge
  76:main.c        **** 	status = AT91C_BASE_PITC->PITC_PIVR;
  77:main.c        **** 	// status = status;
  78:main.c        **** 	
  79:main.c        **** 	systick++;
  80:main.c        **** 	
  81:main.c        **** 	//PRE_INJ2
  82:main.c        **** 	if ((AT91F_PIO_GetInput(AT91C_BASE_PIOB) & PRE_INJ2 ) == PRE_INJ2 ) {
  83:main.c        **** 		AT91F_PIO_ClearOutput( AT91C_BASE_PIOB, PRE_INJ2 );
  84:main.c        **** 	}
  85:main.c        **** 	else  { 
  86:main.c        **** 		AT91F_PIO_SetOutput( AT91C_BASE_PIOB, PRE_INJ2 );
  87:main.c        **** 	}
  88:main.c        **** 	#ifndef CUSTOM_PCB
  89:main.c        **** 	// detect switch-states
  90:main.c        **** 	if ( (AT91F_PIO_GetInput(AT91C_BASE_PIOA) & SW1_MASK ) != SW1_MASK ) {
  91:main.c        **** 		sw1cnt++;
  92:main.c        **** 	}
  93:main.c        **** 	else {
  94:main.c        **** 		sw1cnt=0;
  95:main.c        **** 	}
  96:main.c        **** 	if ( (AT91F_PIO_GetInput(AT91C_BASE_PIOA) & SW2_MASK ) != SW2_MASK ) {
  97:main.c        **** 		sw2cnt++;
  98:main.c        **** 	}
  99:main.c        **** 	else {
 100:main.c        **** 		sw2cnt=0;
 101:main.c        **** 	}
 102:main.c        **** 	#endif //CUSTOM_PCB
 103:main.c        **** 	
 104:main.c        **** }
 105:main.c        **** 
 106:main.c        **** static void device_init(void)
 107:main.c        **** {
 108:main.c        **** 	// Enable User Reset and set its minimal assertion to 960 us
 109:main.c        **** 	AT91C_BASE_RSTC->RSTC_RMR = AT91C_RSTC_URSTEN | (0x4<<8) | (unsigned int)(0xA5<<24);
 110:main.c        **** 
 111:main.c        **** 	// Set-up the PIO
 112:main.c        **** 	// First, enable the clock of the PIO and set the LEDs in output
 113:main.c        **** 	AT91F_PMC_EnablePeriphClock ( AT91C_BASE_PMC, (1 << AT91C_ID_PIOA) | (1 << AT91C_ID_PIOB)) ;
 114:main.c        **** 
 115:main.c        **** 	// then, we configure the PIO Lines corresponding to LED1 to LED4
 116:main.c        **** 	// to be outputs. No need to set these pins to be driven by the PIO because it is GPIO pins only.
 117:main.c        **** 	AT91F_PIO_CfgOutput( AT91C_BASE_PIOA, LED_MASK ) ;
 118:main.c        **** 	AT91F_PIO_CfgOutput( AT91C_BASE_PIOB, PIOB_MASK ) ;
 119:main.c        **** 	
 120:main.c        **** 	AT91F_PIO_SetOutput( AT91C_BASE_PIOA, LED_MASK ) ;
 121:main.c        **** 
 122:main.c        **** 	AT91F_PIO_ClearOutput( AT91C_BASE_PIOB, PIOB_MASK ) ;
 123:main.c        **** 
 124:main.c        **** 
 125:main.c        **** /////////////////PWM
 126:main.c        **** AT91F_PMC_EnablePeriphClock ( AT91C_BASE_PMC, 1<<AT91C_ID_PWMC ); // Enable clock to peripheral
 127:main.c        **** AT91F_PIO_CfgPeriph( AT91C_BASE_PIOA, AT91C_PA19_PWM1, 0); // Assign PIOs to PA0 and PA1
 128:main.c        **** AT91F_PIO_CfgPeriph( AT91C_BASE_PIOA, AT91C_PA22_PWM4, 0);
 129:main.c        **** 
 130:main.c        **** AT91C_BASE_PWMC->PWMC_CH[4].PWMC_CMR = ( AT91C_PWMC_CALG | AT91C_PWMC_CPOL | \
 131:main.c        **** PWM_PRESCALE ); // Center align, start high, CUPD=duty, prescale = 2
 132:main.c        **** AT91C_BASE_PWMC->PWMC_CH[4].PWMC_CDTYR = ((MCK * PERIOD_CH0) / (2 * PWM_PRESCALE)) * DUTY_CH0;
 133:main.c        **** AT91C_BASE_PWMC->PWMC_CH[4].PWMC_CPRDR = (MCK * PERIOD_CH0) / (2 * PWM_PRESCALE);
 134:main.c        **** 
 135:main.c        **** AT91C_BASE_PWMC->PWMC_CH[1].PWMC_CMR = ( AT91C_PWMC_CALG | AT91C_PWMC_CPOL | \
 136:main.c        **** AT91C_PWMC_CPD | PWM_PRESCALE ); // Center align, start high, CUPD=period, prescale = 2
 137:main.c        **** AT91C_BASE_PWMC->PWMC_CH[1].PWMC_CDTYR = ((MCK * PERIOD_CH1) / (2 * PWM_PRESCALE)) * DUTY_CH1;
 138:main.c        **** AT91C_BASE_PWMC->PWMC_CH[1].PWMC_CPRDR = (MCK * PERIOD_CH1) / (2 * PWM_PRESCALE);
 139:main.c        **** 
 140:main.c        **** AT91C_BASE_PWMC->PWMC_ENA = AT91C_PWMC_CHID4;
 141:main.c        **** AT91C_BASE_PWMC->PWMC_ENA = AT91C_PWMC_CHID1; 
 142:main.c        **** 
 143:main.c        **** 	
 144:main.c        **** //////////////////
 145:main.c        **** 
 146:main.c        **** 
 147:main.c        **** 
 148:main.c        **** 
 149:main.c        **** 
 150:main.c        **** 	#ifndef CUSTOM_PCB
 151:main.c        **** 	// define switch SW1 and SW2 at PIO input
 152:main.c        **** 	AT91F_PIO_CfgInput(AT91C_BASE_PIOA, SW1_MASK|SW2_MASK);
 153:main.c        **** 	#endif //CUSTOM_PCB
 154:main.c        **** 
 155:main.c        **** 
 156:main.c        **** 	// Set-up PIT interrupt
 157:main.c        **** 	// AT91F_AIC_ConfigureIt ( AT91C_BASE_AIC, AT91C_ID_SYS, RTTC_INTERRUPT_LEVEL,AT91C_AIC_SRCTYPE_IN 158:main.c        **** 	AT91F_AIC_ConfigureIt ( AT91C_BASE_AIC, AT91C_ID_SYS, RTTC_INTERRUPT_LEVEL,AT91C_AIC_SRCTYPE_INT_P 159:main.c        **** 	AT91C_BASE_PITC->PITC_PIMR = AT91C_PITC_PITEN | AT91C_PITC_PITIEN | PIV_200_MS;  //  IRQ enable CP 160:main.c        **** 	AT91F_AIC_EnableIt (AT91C_BASE_AIC, AT91C_ID_SYS);
 161:main.c        **** 
 162:main.c        **** 	// Set-up DBGU Usart ("UART2")
 163:main.c        **** 	AT91F_DBGU_Init();
 164:main.c        **** }
 165:main.c        **** 
 166:main.c        **** static void dump_mem(unsigned long startaddress, int n)
 167:main.c        **** {
 168:main.c        **** 	volatile unsigned long *p;
 169:main.c        **** 	
 170:main.c        **** 	p = (unsigned long*)startaddress;
 171:main.c        **** 	int i;
 172:main.c        **** 	
 173:main.c        **** 	for (i=0; i<n; i++) {
 174:main.c        **** 		iprintf("Addr:0x%08lx = 0x%08lx (0x%04x:0x%04x)\n", 
 175:main.c        **** 			p, *p, (*p)>>16, (*p)&0xffff);
 176:main.c        **** 		p++;
 177:main.c        **** 	}
 178:main.c        **** }
 179:main.c        **** 
 180:main.c        **** static void dump_interrupt_state(void)
 181:main.c        **** {
 182:main.c        **** 	unsigned long cpsr;
 183:main.c        **** 	const unsigned long I_Bit = 0x80;
 184:main.c        **** 	const unsigned long F_Bit	= 0x40;
 185:main.c        **** 	
 186:main.c        **** 	cpsr = IntGetCPSR();
 187:main.c        **** 	
 188:main.c        **** 	iprintf("State : stat-reg 0x%08x -> ", cpsr);
 189:main.c        **** 	
 190:main.c        **** 	if ( cpsr & I_Bit ) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -