ts-7000
[Top] [All Lists]

Re: [ts-7000] Re: ts-7200 onboard ADC help.

To:
Subject: Re: [ts-7000] Re: ts-7200 onboard ADC help.
From: Eddie Dawydiuk <>
Date: Thu, 25 Jan 2007 09:17:24 -0700 (MST)
Hello,

> To my experience, there is conflicting information on the data mask
> between what Cirius provides in it's manual.
>
> Page 519 - EP9301 User Manual
> AD : Converter output at 12 bit resolution.
>
> Page 28 - TS-7250 Hardware Manual
> The reference point are stored in a 16 bit value.

Take a look at the EP9301 datasheet, specifically page 33. You'll find a
16 bit signed value is returned. The value ranges from 0x9E58 to
0x61A8.

http://www.cirrus.com/en/pubs/proDatasheet/EP9301_PP5.pdf

> Please advise is this work with your code because I had lots of
> problems recently.  Using the sample code from the Devkit CD, I made a
> function called inside a service (looping)... after 1-2 hours, the
> services crash because of "too many files open (VFS error from Linux)".

The only file opened by the sample code is /dev/mem, and it is being
closed at the end of main... Could you provide more information about
the modifications you made? Are you opening /dev/mem on every loop?

//Eddie

> --- In  "chan8337" <> wrote:
>>
>> According to the EP9301 user manual, i have written a sample code to
>> read a voltage level on the GPI0 pin4 which is portC bit0. Once the
>> code is running, i cant get a accurate result. Let say i set the input
>> voltage to 1V but on the terminal the displayed voltage level keep
>> varying.
>>
>> Maybe i missed something that must set in the registers.
>> I have read the sample code provided from Embededarm website. But I
>> cant understand it. It seem like I must correct the ADCResult with the
>> caribration value stored inside the EEPROM.
>>
>> Anyone please help?
>>
>> Just for your info my board is based on the EP9302-CQ cirrus arm
>> processor. Is the register addresses inside the EP9301 user munual
>> valid for EP9302?
>>
>> Below shows the code that i have written.
>> --------------------------------------------------------------------
>> #include<sys/types.h>
>> #include<sys/mman.h>
>> #include<stdio.h>
>> #include<fcntl.h>
>> #include<string.h>
>>
>> main(int argc, char **argv)
>> {
>> volatile unsigned int *SysSWLock, *ADCClkDiv, *DevCfg, *ADCSWLock,
>> *ADCResult, *ADCSwitch, *PBDDR, *PBDR, *GPIOBDB;
>> unsigned char *SysconBase, *ADCBase, *start;
>>
>> float ADResult;
>> unsigned char state;
>>
>> int fd = open("/dev/mem", O_RDWR);
>> SysconBase = mmap(0, getpagesize(), PROT_READ|PROT_WRITE, MAP_SHARED,
>> fd, 0x80930000);
>> ADCBase = mmap(0, getpagesize(), PROT_READ|PROT_WRITE, MAP_SHARED, fd,
>> 0x80900000);
>> start = mmap(0, getpagesize(), PROT_READ|PROT_WRITE, MAP_SHARED, fd,
>> 0x80840000);
>>
>> /*Assign register addresses to pointers according to ep9301 user guide*/
>> SysSWLock = (unsigned int *)(SysconBase + 0xC0);
>> ADCClkDiv = (unsigned int *)(SysconBase + 0x90);
>> DevCfg = (unsigned int *)(SysconBase + 0x80);
>> ADCSWLock = (unsigned int *)(ADCBase + 0x20);
>> ADCResult = (unsigned int *)(ADCBase + 0x08);
>> ADCSwitch = (unsigned int *)(ADCBase + 0x18);
>>
>> PBDDR = (unsigned int *)(start + 0x14); //port b direction
>> PBDR = (unsigned int *)(start + 0x04); //port b
>> GPIOBDB = (unsigned int *)(start + 0xC4); // debounce on port b
>>
>> /*Setup the PortB to received digital input*/
>> *PBDDR = 0xf0; //upper nibble output, lower nibble input
>> *GPIOBDB = 0x01; //enable debounce on bit 0
>>
>> /*Steps to setup the onboard ADC for ts-7200*/
>> *SysSWLock = 0xAA; //unlock the software lock for the all registers
>> *ADCClkDiv |= 0x80010000; //enable TSEN(bit32)-AD clock start, enable
>> ADIV(bit16)-AD clk/4
>>
>> *SysSWLock = 0xAA; //unlock the software lock for the all registers
>> (AGAIN)
>> *DevCfg |= 0x00020000; //Set the ADCEN - ADC enable.
>>
>> *SysSWLock = 0xAA; //unlock the software lock for the all registers
>> (AGAIN)
>> *DevCfg &= 0xFFFFFFFB; //Clear the ADCPD-ADC. Set 1 to Power Down
>>
>> *ADCSWLock = 0xAA; //unlock the software lock for the all registers
>> (AGAIN)
>> *ADCSwitch = 0x00000608; //Enable AD channel 4 to receive analog signal.
>>
>> /*do while loop is terminated when portb bit0 is "0". Default pull up
>> to logic "1"*/
>>   do
>>   {
>>     state = *PBDR;
>>     while((*ADCResult & 0x80000000)==0x80000000); //pooling until
>> bit31 set then exit.
>>     ADResult = ((float)(*ADCResult & 0x00000FFF)/4095)*3;
>>     printf("Channel 0 Result: %f \n", ADResult);
>>
>>   }while(state & 0x01);
>>
>> close(fd);
>> return 0;
>>
>> }
>>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/ts-7000/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/ts-7000/join
    (Yahoo! ID required)

<*> To change settings via email:
     
    

<*> To unsubscribe from this group, send an email to:
    

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU