--- In Jim Jackson <> wrote:
>
>
>
>
> On Mon, 21 Nov 2011, thoff88 wrote:
>
> > I am fairly new to the ts7250 and I'm trying to control the DIO pins.
> > When I toggle the pins in a for loop nothing happens unless there is a
> > printf() statement within the loop. I am using rtai functions so I can
> > use the real time timer between the loop iterations, yet the pins still
> > only toggle when there is a printf() statement in the loop.
> >
> > If anyone has suggestions to what may be causing this it would be very
> > appreciated.
>
> Without code it's like being mystic meg :-)
> But probably because you haven't declared your pointers as volatile.
> Or not using the correct options in mmap? e.g.
>
Thank you for the quick response. Here is the code I am using. It only outputs
a 100 Hz square wave when I use the printf() statement.
void pwm() {
int i = 0;
volatile unsigned long *start;
volatile unsigned long *PBDR, *PBDDR;
int fd = open("/dev/mem", O_RDWR);
start = mmap(0, getpagesize(), PROT_READ|PROT_WRITE, MAP_SHARED, fd,
0x80840000);
PBDR = (start + 0x01);
PBDDR = (start + 0x05);
*PBDDR = 0xF0;
//create realtime task
RT_TASK* rt_task = rt_task_init(nam2num("thrd1"), 0, 0, 0);
rt_task_make_periodic(rt_task, rt_get_time(), timer*5);
for(i=0;i<5000;i++) {
//printf("line\n");
*PBDR = *PBDR ^ PIN15ON;
rt_task_wait_period();
}
close(fd);
rt_task_delete(rt_task);
pthread_exit(0);
}
> volatile unsigned char * ptr = mmap(0,getpagesize(),PROT_READ|PROT_WRITE, \
> MAP_SHARED,fd,address)
>
------------------------------------
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/
|