On Tue, 5 Jul 2011, Don Tucker wrote:
> Thanks, Jim. I changed PBDR and PBDDR from unsigned int to unsigned char.
> PBDR, and PBDDR look like what I would expect, but I'm not sure what I should
> be seeing for start.
what you see is what you get - The page address returned by the mmap call.
You see that in actual fact PBDR IS start+0x4 and PBDDR IS start + 0x14
If you had used unsigned int * they would NOT have been what you expected.
When you write/read from these addresses you ARE accessing the correct
locations.
cheers
Jim
> start= 2AAC9000, PBDR= 2AAC9004, PBDDR= 2AAC9014.
>
> On 7/2/2011 3:48 AM, Jim Jackson wrote:
> >
> >
> > As I said in another thread only the other day, you have to be carefull
> > when using integer pointers[1].
> >
> > Change your pointers to "unsigned char *" from "unsigned int *"
> >
> > Jim
> >
> > [1] you might try printing out the hex values of start, PBDR & PBDDR,
> > and see if the numbers are what you think they should. You will
> > find they are start+0x10, start+0x50
> >
> > To C the address of (start+0x04) is the same as the address of start[4]
> > (the fourth integer in the integer array start) which is of course at
> > start+16 or start+0x10. As I said above using byte pointers is sooooo much
> > easier.
> >
> > On Fri, 1 Jul 2011, Rekcut_Nod wrote:
> >
> > > I'm attempting to run the TS sample from:
> > >
> > > ftp://ftp.embeddedarm.com/ts-arm-sbc/ts-7260-linux/samples/button.c
> > >
> > > modified slightly to toggle output on the DIO1 header, rather than the
> > > on-board LEDs. I'm monitoring DIO1 pin 9 (DIO_4) with a volt meter
> > > across a resister to ground, and it reads a constant 5.6mV, even when the
> > > program enters into the toggle loop.
> > >
> > > Can anyone tell me what I need to do differently?
> > >
> > > Don
> > >
> > >
> > > 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|O_SYNC);
> > >
> > > start = mmap(0, getpagesize(), PROT_READ|PROT_WRITE, MAP_SHARED, fd,
> > 0x80840000);
> > > PBDR = (unsigned int *)(start + 0x04); // port b
> > > PBDDR = (unsigned int *)(start + 0x14); // port b direction register
> > > 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
> > > while (state & 0x01) { // wait until button goes low
> > > state = *PBDR; // remember bit 0 is pulled up with 4.7k ohm
> > > }
> > >
> > >
> > > // blink 5 times, sleep 1 second so it's visible
> > > for (i = 0; i < 5; i++) {
> > > *PBDR = 0xf0;
> > > sleep(1);
> > > *PBDR = 0x00;
> > > sleep(1);
> > > }
> > > 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/
|