Skip to contentSkip to conversation

RTC with TQM823L

DISCUSSION Jean Nicollerat MD 4 participants 6 messages Mar 17, 2005

lore
Share & tools
lore
#0 lore raw

Hello,
I need to have an interrup every 10ms in my application running in linux. I have a PowerPC 823 on the board TQM823L LCD from denx.
I use the ocan driver.
I try to use the RTC modules but with the code :

	fd = open ("/dev/rtc", O_RDONLY);

	if (fd ==  -1) {
		perror("/dev/rtc");
	}
	/* Turn on update interrupts (one per second) */

	retval = ioctl(fd, RTC_UIE_ON, 0);
	if (retval == -1) {
		perror("ioctl");
		//exit(errno);
	}

I get an error message :
ioctl : invalide argument # for then line :"retval = ioctl(fd, RTC_UIE_ON,
0);"

Can somebody help ? why it is not working or a better way to get function called each 10ms

Thanks

Jean

#1 lore raw
Quoted 2 lines · In message <[email protected]> you wrote:

I need to have an interrup every 10ms in my application running in linux.

This is an oxymoron. Interrups are processed in kernel space, applications are running in userspace. You cannot process interrupts in aplication code.

Quoted 8 lines

I try to use the RTC modules but with the code :

	fd = open ("/dev/rtc", O_RDONLY);

	if (fd ==  -1) {
		perror("/dev/rtc");
	}
	/* Turn on update interrupts (one per second) */

You mentioned you wanted signals (not interrupts) every 10 millisec, not every second -- what exactly is it that you want?

Quoted 1 line
	retval = ioctl(fd, RTC_UIE_ON, 0);

...

Quoted 2 lines

ioctl : invalide argument # for then line :"retval = ioctl(fd, RTC_UIE_ON,
0);"

Which means that the driver does not support this ioctl.

Quoted 2 lines

Can somebody help ? why it is not working or a better way to get function called each 10ms

You can use setitimer. But be warned. Your requirement of having signals every 10 milliseconds means that there is a serious problem with your software design. You are doing someting really, really wrong. To me it sounds as if you try to implement your own timer based control loop in user space with an insane smapp period. This will never work reliably (as there is no guarantee that your tasks will be scheduled in time), and will waste a lot of CPU power.

Never take existing software designs from other operating system environments and put them without thinking into a Unix environment. Often there are much better and more efficient approaches in Unix.

Just in case you really must stick with that 10 millisecond raster:
in this case you will probably have to use RTAI (especially on a resource-limted CPU like the 823).

Best regards,

Wolfgang Denk

Signature · 4 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected]
The trouble with our times is that the future is not what it used  to
be.                                                     - Paul Valery
#5 lore raw
In reply to Jean Nicollerat MD

Can't you use a cpmtimer to fire every 10ms and wakeup a high priority thread?

Jaap-Jan

Quoted 35 lines · Jean Nicollerat MD

Hello,
I need to have an interrup every 10ms in my application running in linux. I have a PowerPC 823 on the board TQM823L LCD from denx.
I use the ocan driver.
I try to use the RTC modules but with the code :

	fd = open ("/dev/rtc", O_RDONLY);

	if (fd ==  -1) {
		perror("/dev/rtc");
	}
	/* Turn on update interrupts (one per second) */

	retval = ioctl(fd, RTC_UIE_ON, 0);
	if (retval == -1) {
		perror("ioctl");
		//exit(errno);
	}

I get an error message :
ioctl : invalide argument # for then line :"retval = ioctl(fd,
RTC_UIE_ON,
0);"

Can somebody help ? why it is not working or a better way to get function called each 10ms

Thanks

Jean

_______________________________________________
Linuxppc-embedded mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-embedded

#2 lore raw
In reply to Wolfgang Denk

Thanks for your answer.
I'm used to program on processor without OS. I want try linux to use linux to have have LCD, ethernet, USB, ... , dirvers.
I have to read message that comme on the CAN bus every 2ms. Then I have to show values on the LCD and transfers some message on the RS232. I need a timer to the check the reception of the messages.
I seem it is difficult with linux. I will try with the RTAI.

regards
Jean Nicollerat

regards
-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Thursday, March 17, 2005 9:34 AM
To: Jean Nicollerat MD
Cc: [email protected]
Subject: Re: RTC with TQM823L

In message <[email protected]> you

Quoted 2 lines · wrote:

I need to have an interrup every 10ms in my application running in linux.

This is an oxymoron. Interrups are processed in kernel space, applications are running in userspace. You cannot process interrupts in aplication code.

Quoted 8 lines

I try to use the RTC modules but with the code :

	fd = open ("/dev/rtc", O_RDONLY);

	if (fd ==  -1) {
		perror("/dev/rtc");
	}
	/* Turn on update interrupts (one per second) */

You mentioned you wanted signals (not interrupts) every 10 millisec, not every second -- what exactly is it that you want?

Quoted 1 line
	retval = ioctl(fd, RTC_UIE_ON, 0);

...

Quoted 1 line

ioctl : invalide argument # for then line :"retval = ioctl(fd,

RTC_UIE_ON,

Quoted 1 line

0);"

Which means that the driver does not support this ioctl.

Quoted 2 lines

Can somebody help ? why it is not working or a better way to get function called each 10ms

You can use setitimer. But be warned. Your requirement of having signals every 10 milliseconds means that there is a serious problem with your software design. You are doing someting really, really wrong. To me it sounds as if you try to implement your own timer based control loop in user space with an insane smapp period. This will never work reliably (as there is no guarantee that your tasks will be scheduled in time), and will waste a lot of CPU power.

Never take existing software designs from other operating system environments and put them without thinking into a Unix environment. Often there are much better and more efficient approaches in Unix.

Just in case you really must stick with that 10 millisecond raster:
in this case you will probably have to use RTAI (especially on a resource-limted CPU like the 823).

Best regards,

Wolfgang Denk

--
Software Engineering: Embedded and Realtime Systems, Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected] The trouble with our times is that the future is not what it used to
be. - Paul Valery

#3 lore raw
Quoted 2 lines · In message <[email protected]> you wrote:

I'm used to program on processor without OS. I want try linux to use linux

That was what I expected from your posting.

Quoted 2 lines

I have to read message that comme on the CAN bus every 2ms. Then I have to show values on the LCD and transfers some message on the RS232.

Ok.

Quoted 1 line

I need a timer to the check the reception of the messages.

No. This is fundamentally wrong. You do NOT need a timer to check if a device driver has data available.

This is exactly what I meant when sayin you will have to get used to working in a Unix environment., Under Unix, you will not use a time triggered control loops which polls all your drivers, but you will use select() or poll() to wait for events from your drivers. It's the incoming data which triggers your control loop, not a timer.

Quoted 1 line

I seem it is difficult with linux. I will try with the RTAI.

DO NOT DO IT. This will only make things worse. You are on the wrong track. Don't try to stick with a software design which does not fit any more. Change your design to take advantage of the services provided by a Unix operating system.

Best regards,

Wolfgang Denk

Signature · 3 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected]
Never call a man a fool.  Borrow from him.
#4 lore raw
In reply to Jean Nicollerat MD
Quoted 2 lines · Jean Nicollerat MD

I have to read message that comme on the CAN bus every 2ms. Then I have to show values on the LCD and transfers some message on the RS232.

Sounds like a simple device driver would handle this.

Quoted 1 line

I need a timer to the check the reception of the messages.

Could this be done by setting a timeout which you keep rescheduling?

Note that the standard clock tick on linux has 10ms resolution - i.e. 100Hz. You might want to increase this to 1000Hz (i.e. 1ms resolution). I have read of people doing this in this list.

Quoted 1 line

I seem it is difficult with linux.

No, its not difficult at all - its very easy. There is a learning curve though, just like anything. Cheers!

                                                                Murray...

--
Murray Jensen, CSIRO Manufacturing & Infra. Tech. Phone: +61 3 9662 7763
Locked Bag No. 9, Preston, Vic, 3072, Australia. Fax: +61 3 9662 7853
Internet: [email protected]

To the extent permitted by law, CSIRO does not represent, warrant and/or guarantee that the integrity of this communication has been maintained or that the communication is free of errors, virus, interception or interference.

The information contained in this e-mail may be confidential or privileged. Any unauthorised use or disclosure is prohibited. If you have received this e-mail in error, please delete it immediately and notify Murray Jensen on +61 3 9662 7763. Thank you.