ts-7000
[Top] [All Lists]

Re: [ts-7000] Re: DIO inputs

To: <>
Subject: Re: [ts-7000] Re: DIO inputs
From: salva g <>
Date: Sat, 17 Oct 2009 16:03:29 +0200


With this modification, the code

> // state = *PBDR; not used now
> if (oldstate != *PBDR)
> {
> printf ("State:%o\n", *PBDR);

prints all the values in the registers.
But, the other question, somebody could explain me this line?
       *GPIOBDB = 0x01; //enable debounce on bit 0
(Sorry for the octal mode, it was a proof, must be %x)

naturalwatt escribió:
>
> I have pretty much identical code and it works fine for me.
>
> However you say you can only see two hexadecimal chars.
>
> The variable 'state' is a char, it's 8 bits wide, hence two hex chars. Why would you expect 4? And you are printing in Octal, which might confuse you.
>
> I must admit I'm puzzled why the PBDR variables are int *, not char *, but my code is the same.
>
> --- In salva g ...> wrote:
> >
> >
> > Hi, I have read a lot of, I think, from the forum but...here is my problem: (TS7800)
> > I'm working with this code
> >
> > #includeh>
> > #includetypes.h>
> > #includemman.h>
> > #includeh>
> > #includeh>
> > #includeh>
> >
> > #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|O_SYNC);
> >
> > 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 = E80 000 004
> > PBDDR = (unsigned int *)(start + 0x14); //port b direction
> >
> > GPIOBDB = (unsigned int *)(start + 0xC4); // debounce on port b
> >
> > *PBDDR = 0x00; // all(8) inputs
> > *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:%o\n", state);
> > oldstate = state;
> > }
> > usleep(1000);
> >
> > }
> > printf ("\nDONE\n");
> > close(fd);
> > return 0;
> > }
> >
> > but only have an answer in the shell when I short with ground (pin 2) the 1,3,5, or 7 pin DIO.
> > shorting the other 9,11,13,15, nothing happens, but with peek32 0xE8000004, I can see the changes, the problem is that the program shows only 2 hexadecimal characters. If I could see 4 of them, it will be solved.
> > And, I don't know why doesn't matter if I put (*PBDDR = 0x00 //all inputs) or (*PBDDR = 0xf0;): the program works equal in both.
> > Also, somebody could explain me the line: *GPIOBDB = 0x01; //enable debounce on bit 0
> >



Entra al Nuevo Canal Motor y descubre por qué los coches más rápidos sólo aparcan en MSN. Nuevo diseño, más completo y abierto a tu opinión. ¡Nuevo Canal Motor!

__._,_.___


Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: =Email Delivery: Digest | m("yahoogroups.com?subject","ts-7000-fullfeatured");=Change Delivery Format: Fully Featured">Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | =Unsubscribe

__,_._,___
<Prev in Thread] Current Thread [Next in Thread>
  • Re: [ts-7000] Re: DIO inputs, salva g <=
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