LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 05-04-2013, 04:01 PM   #1
oz6oh
LQ Newbie
 
Registered: Mar 2009
Location: denmark ballerup
Distribution: 13.04
Posts: 4

Rep: Reputation: 0
something about my strobe programming


TheNbomr gave me an answer about programming my strobe thank, but i am newbeginner. On my parrallelport leg 1 2 3 4 5 6 7 8 9 i have strobe as number 1 and i want to program strobe on or out but stil have my other legs working as 1 2 4 8 16 32 64 128. I would like to use my spacetast as pressed strobe on and unpressed as strobe off. I can se something is done with strobe when i try to add 2 on 278+2 Then i se strobe is working but not on the right manner. #include <stdio.h>//In use
#include <stdlib.h>// In use
#include <sys/io.h>//In use
#define base 0x378 /*Here is Port defined*/

main(int argc, char **argv)
{
int x;
int value;
x = 0;
value=0;
if (ioperm(base, 4, 1))
{
perror("ioperm"); exit(1);// Use sudo !
}
while(1)
{
printf("\nInput fra 0 til 255 ");
scanf("%d",&x);
value = (x);
printf("\nPortout= %d", value); /* Show Output on Led's */
outb(value, base);
}
}

#define base 0x378+2 will programme strobe on and out vhen i give input

1 2 3 4 up to 255 but my dato on D0 D3 D2 D3 D4 D5 D6 D7 D8 are not working more. Therefor my new question about strobe I think i shall invoke a case statement ? Here my first case beginning program

#include <stdio.h>//In use

int main() {

int x = 1;

printf("Vaelg 1: Strobe on,2: Strobe off:\n");

scanf("%d", &x);
{
switch (x) {
case 1:
//Here i think i shall work with ports
printf(" Strobe on\n");// led 1 on
break;
case 2:
//Here i also shall work with ports
printf("Strobe off\n");//;Led 1 off
break;
}

return 0;

}

in case 1 and case 2 i shall give som portcommmands ? But how ???

Hope somebody understand my questions Thanks all here Ole
 
Old 05-06-2013, 11:44 AM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Pull out your C language textbook, and learn about the operators '|' (bit-wise OR) and '&' (bit-wise AND), and while you're in the neighborhood, learn about '^' (exclusive-OR) as well. Understanding those operators is the key to knowing how to set & clear specific bits in a word. Since you're already using outb() to write to the port, consider using inb() to read from the register. Modify the value that you read from the port using bit-wise logic operators, then write the result back out.

Please:
  • Don't shout
  • Post source code in [CODE] [/CODE] tags to preserve formatting

--- rod.

Last edited by theNbomr; 05-06-2013 at 11:47 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i program strobe on and off oz6oh Programming 1 05-01-2013 10:11 AM
jack "strobe" tuning program ninja master Programming 0 10-01-2011 12:24 AM
Why the STROBE pin in parallel port?? arunshivanandan Linux - General 3 09-01-2004 09:28 AM


All times are GMT -5. The time now is 05:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration