First off al Sorry it's 3v not 1v.
Please see Edited value of *PCDR Register.Is any Modification still
Require.Will It work???
int main(int argc, char **argv)
{
unsigned char *start;
volatile unsigned int *PCDR, *PCDDR;
int fd = open("/dev/mem", O_RDWR);
start = mmap(0, getpagesize(), PROT_READ|PROT_WRITE, MAP_SHARED, fd,
0x80840000);
PCDR = (unsigned int *)(start + 0x08); // port c data register
PCDDR = (unsigned int *)(start + 0x18); // port c direction register
*PCDDR = 0x01; // Make bit 0 an output Port C bit 0 is connected to the LED
*PCDR &= 0xFE; // Turn the LED off
sleep(30); // Output on for 30 seconds
*PCDR |= 0x01; // Turn the LED on
close(fd);
return 0;
}
--- In "Charles" <> wrote:
>
> --- In "amit" <ts7300@> wrote:
> >
> > Please suggest me something.
> > Waiting for some Response...
> > --- In "ts7300" <ts7300@> wrote:
> > >
> > > Can somebody assist me upon this.
> > > By default 3V is coming at DIO1 pin4.what data register value I supposed
> > > to set to toggle the o/p 3.3v and 0v.
> > > Will it be PCDR:0xFE for 0v??
> > > PCDR:0X01 FOR 1V.??
>
> No. As Jason suggested, these are binary, on-or-off.
>
> > > --- In "ts7300" <ts7300@> wrote:
> > > >
> > > > Have doubt in manual mention make bit0 as output for portC.For LED ON
> > > > *PCDR &= 0xFF; and For LED OFF *PCDR &= 0x00; These data value I have
> > > > to Give.
> > > > --- In "ts7300" <ts7300@> wrote:
> > > > >
> > > > > I am using TS-7300 and want to control the I/0 of board via
> > > > > connecting LED to I/O Board.And using DIO1 PIN4 of board.
> > > > > Below are the C code:
> > > > > #include<unistd.h>
> > > > > #include<sys/types.h>
> > > > > #include<sys/mman.h>
> > > > > #include<stdio.h>
> > > > > #include<fcntl.h>
> > > > > #include<string.h>
> > > > >
> > > > > int main(int argc, char **argv)
> > > > > {
> > > > > unsigned char *start;
> > > > > volatile unsigned int *PCDR, *PCDDR;
> > > > > int fd = open("/dev/mem", O_RDWR);
> > > > >
> > > > >
> > > > > start = mmap(0, getpagesize(), PROT_READ|PROT_WRITE, MAP_SHARED,
> > > > > fd, 0x80840000);
> > > > > PCDR = (unsigned int *)(start + 0x08); // port c data register
> > > > > PCDDR = (unsigned int *)(start + 0x18); // port c direction
> > > > > register
> > > > >
> > > > > *PCDDR = 0x01; // Make bit 0 an output Port C bit 0 is connected
> > > > > to the LED
>
> You just clobbered whatever else was in *PCDDR already. Use
> *PCDDR |= 0x01 to do this without clobbering other data in the register.
>
> > > > >
> > > > > *PCDR &= 0xFE; // Turn the LED on
>
> *PCDR |= 0x01 // Turn on bit 1 without affecting other bits
>
> > > > > sleep(30); // Output on for 30 seconds
> > > > > *PCDR |= 0x01; // Turn the LED off
>
> *PCDR &= 0xFE // Turn off bit 1 without affecting other bits
>
> Note that 0xFE = ~0x01. Manipulating bit values like this will be very
> important in the rest of your class ....
>
> regards, ........ Charlie
>
> > > > >
> > > > > close(fd);
> > > > > return 0;
> > > > > }
> > > > > And Problem is that after 30 seconds its no becoming low(LED
> > > > > off).Keep on giving +3V on PIN4 of Board.
> > > > > Will anybody have an idea about that???
> > > > >
> > > >
> > >
> >
>
------------------------------------
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/
|