📄 externalmemory.c
字号:
/********************************************************************
Author : ADI - Apps www.analog.com/MicroConverter
Date : May. 2007
File : ExternalMemory.c
Hardware : Applicable to ADuC7026 with External SRAM ( 64K CY7C1020 )
Description : ADC converts on Channel 0 for "Number_of_Samples" and stores
results in External Memory.
Notes : This programme requires use of the "ADI702x_FLASH_ExternalMemory.xcl"
linker script which defines the external memory segments.
The GPIO are configured for external memory use in Low_Level_init().
If the GPIO are not configured, Data aborts will be generated when
external memory is accessed.
********************************************************************/
#include "ioaduc7026.h"
#define Number_of_Samples 30000
void ADCpoweron(int time);
void start_conversion(void);
unsigned short TableS[Number_of_Samples] ;
int main (void) {
ADCpoweron(20000); //Power on ADC
ADCCP = 0x00; //Select ADC channel 0
REFCON = 0x01; //Internal 2.5V reference. 2.5V on Vref pin
start_conversion(); // Begin ADC Conversions
while(1){}
}
void start_conversion(void){
int i;
ADCCON = 0x6E4; //Start continuous conversion
for(i=0;i<Number_of_Samples;i++)
{
while(!ADCSTA){} //Wait for end of conversion
TableS[i] = (ADCDAT >> 16); //Store converison in external ram
}
ADCCON = 0x0; //Stops continuous conversion
}
void ADCpoweron(int time) {
ADCCON = 0x620; // power-on the ADC
while (time >=0) // wait for ADC to be fully powered on
time--;
}
// IMPORTANT - The amount of stack spaces allocated for the IRQ stack is
// defined by _IRQ_STACK_SIZE in the linker script file. If you add
// additional function calls or additional local variables then
// you should verify that _IRQ_STACK_SIZE is still sufficiently
// large to prevent overflow of the stack and corruption of data
__irq __arm __ramfunc void irq_handler(void) // IRQ Handler
{
while (1);
}
// IMPORTANT - The amount of stack spaces allocated for the UND stack is
// defined by _UND_STACK_SIZE in the linker script file. If you add
// additional function calls or additional local variables then
// you should verify that _UND_STACK_SIZE is still sufficiently
// large to prevent overflow of the stack and corruption of data
//
// hander must be compiler for arm. Using __irq for the function prologue,
// function should perform some useful operation rather than just simply
// returning to the instruction that caused the execption
__irq __arm void undef_handler(void) // IRQ Handler
{
while (1);
}
// IMPORTANT - The amount of stack spaces allocated for the ABT stack is
// defined by _ABT_STACK_SIZE in the linker script file. If you add
// additional function calls or additional local variables then
// you should verify that _ABT_STACK_SIZE is still sufficiently
// large to prevent overflow of the stack and corruption of data
//
// hander must be compiler for arm. Using __irq for the function prologue,
// function should perform some useful operation rather than just simply
// returning to the instruction that caused the execption
__irq __arm void prefetch_handler(void) // prefetch Handler
{
while (1);
}
// IMPORTANT - The amount of stack spaces allocated for the ABT stack is
// defined by _ABT_STACK_SIZE in the linker script file. If you add
// additional function calls or additional local variables then
// you should verify that _ABT_STACK_SIZE is still sufficiently
// large to prevent overflow of the stack and corruption of data
//
// hander must be compiler for arm. Using __irq for the function prologue,
// function should perform some useful operation rather than just simply
// returning to the instruction that caused the execption
__irq __arm void data_handler(void) // data Handler
{
while (1);
}
// IMPORTANT - The amount of stack spaces allocated for the FIQ stack is
// defined by _FIQ_STACK_SIZE in the linker script file. If you add
// additional function calls or additional local variables then
// you should verify that _FIQ_STACK_SIZE is still sufficiently
// large to prevent overflow of the stack and corruption of data
//
__fiq __arm void fiq_handler(void) // fiq Handler
{
// Replace this while (1) code with a proper handler for the fiq source
while (1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -