ADC -mini6410 - segmentation fault

ocikgel
hi  everybody ,
I have mini6410  and I want to use analog inputs , but I am new at this
topic and I need help. I wrote some code and compile with arm-linux-gcc
and upload mini6410 and try this code but I have segmentation fault in run
time.

Can you help me ? what is the problems and solutions ? 

best regards.


//////////////////////////////////////////////////////////////////////
.....
.....
.....


// A/D Converter
#define ADCCON               (*( unsigned long *) 0x7E00B000)  
#define ADCTSC               (*( unsigned long *) 0x7E00B004) 
#define ADCDLY               (*( unsigned long *) 0x7E00B008) 
#define ADCDAT0              (*( unsigned long *) 0x7E00B00C) 
#define ADCDAT1              (*( unsigned long *) 0x7E00B010) 
#define ADCUPDN              (*( unsigned long *) 0x7E00B014)

void initADC()
{
  
  ADCCON =   (1<<16); //select 12 bit /* !!! segmentation fault */
  
  ADCCON =   (1<<14); //A/D converter prescaler enable 
 
  ADCCON =   (0<<5); //chanel select [5:3] 001 is AIN1
  ADCCON =   (0<<4);
  ADCCON =   (1<<3);
  
  ADCCON =   (0<<2); //Standby mode select = normal mode
 
  ADCCON =   (1<<1)  //A/D conversion start by read 
}
........
........
........
/////////////////////////////////////////////////////////////////////

ocikgel
ps : I also tried (*( volatile unsigned long *) this but I had again
segmentation fault

davef
I can only talk from my 8bit experience and even that could be incorrect.

First, I would have thought that something like #define ADCTSC would
already be done for you.  Perhaps, you are trying to do it the hard way for
some experience. Are you sure you have the locations? Also, I think they
are normally done like your 2nd post, i.e. volatile.

Secondly, a statement like:
ADCCON = (1<<16) may not be doing what you expect.

I would have done ADCCON |= (1<<16) or even better still there is probably
an ADC register name like, ADCSR and some bit names for the various
functions within that register like ADCON that would allow you to do:

ADCSR |= (1 << ADCON);  i.e turn ADC on

The |= says ONLY change (set) that particular bit and don't mess with any
of the others. ADCCON = (1<<16); could be messing with other bits in that
register.

Clearing bits is done like this:

ADCSR &= ~(1 << ADCON); i.e. turn ADC off.

Abuda
Try this.

echo 2 > /proc/cpu/alignment