ts-7000
[Top] [All Lists]

Re: [ts-7000] DIO output TS-7260

To:
Subject: Re: [ts-7000] DIO output TS-7260
From: Don Tucker <>
Date: Tue, 05 Jul 2011 09:10:54 -0500
Thanks, Mahendiran.  I know that this portion of my code works, since
the program will wait forever until I ground DIO1 pin 1, as it should.

Don

On 7/2/2011 3:58 AM, mahendiran gopal wrote:
Hi,
Remove the below code in your program and compile then try it will work.
 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
 }
Regargs,
Mahendiran
India


On Sat, Jul 2, 2011 at 2:18 PM, 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;
    > }
    >
    >




Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

<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