ts-7000
[Top] [All Lists]

Re: [ts-7000] Odd results Polling DIO on 7800

To:
Subject: Re: [ts-7000] Odd results Polling DIO on 7800
From: Jim Jackson <>
Date: Tue, 5 Aug 2008 11:14:39 +0100 (BST)

Try making your pointer unsigned char *

On Mon, 4 Aug 2008, eric.robishaw wrote:

> Attempting to poll the DIO lines on 7800.
> (I've modified the button example to use as a base for polling the DIO
> lines.)
>
> CODE BELOW
>
> However, there are some strange issues I can't figure out.
>
>    1. If I short pins 2 (ground*) to the odd numbered pins (HI via 2.2K)
> I expect value changes on the DIO line, but only get changes in pins:
> 1, 3 & 5
>    2. If I short pins 16 (3.3V) to even pins (except pin 10), I only get
> value changes on:
> 4 AND 8
>    3. I can't make heads or tails of the return values.
> For example:
>
> No pins shorted = 0x15
>
> Pin 1 =0x14,
> Pin 3 = 0x11,
> Both 1 & 3 = 0x10
>
> How is 0x10 derived from 0x14 AND 0x11?
> In binary:
> 0x11: 0001 0001
> 0x14:0001 0100
> 0x10:00010000
>
> It's obviously not ored, anded or Xored.
>
> The Bottom line question is this:
> How do I determine which pins are shorted from the value of state (see
> code)
> Why do I not get state changes from pins 6,7,9-15
>
>
>
> BEWARE: the 7800 manual is incorrect.  According to the specs, pin 2 is
> Ground (not an input/output) and pin 16 is 3.3V (again, not an IO line)
>
> CODE:
>
> #define DIOBASE 0xE8000000
> int main(int argc, char **argv)
> {
>     volatile unsigned int *PBDR, *PBDDR, *GPIOBDB;
>
>     int i;
>     unsigned char state;
>     unsigned char *start;
>     int fd = open("/dev/mem", O_RDWR);
>
>     start = mmap(0, getpagesize(), PROT_READ|PROT_WRITE, MAP_SHARED, fd,
> DIOBASE);
>
>     PBDR = (unsigned int *)(start + 0x04); //port b
> //starting address of DIO read, E8000000 + 4 = E80000004
>     PBDDR = (unsigned int *)(start + 0x14); //port b direction
>
>     GPIOBDB = (unsigned int *)(start + 0xC4); // debounce on port b
>
>     *PBDDR = 0xf0; //upper nibble output, lower nibble input
>     *GPIOBDB = 0x01; //enable debounce on bit 0
>     state = *PBDR; // read initial state
>
>     printf ("Press buttons on DIO inputs. Ctrl-C to Quit.\n");
>
>     int count = 0;
>     unsigned char oldstate = (unsigned char)0;
>     while (1) //(state & 0x01)
>     {
>         state = *PBDR; // remember bit 0 is pulled up with 4.7k ohm
>         if (oldstate != state)
>         {
>             printf ("State:%x\n", state);
>             oldstate = state;
>         }
>         usleep(100);
>         count++;
>     }
>     printf ("\nDONE\n");
>     close(fd);
>     return 0;
> }
>
>
>

------------------------------------

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