Attached. One is the cpp code and other is the bash script. cpp code uses the GPIO class from the attached GPIO.7z .
On Thursday, July 14, 2016 at 9:50:45 AM UTC+5:30, William Hermans wrote: > > Let's put it this way. No code, no help . . . > > On Wed, Jul 13, 2016 at 9:19 PM, William Hermans <[email protected] > <javascript:>> wrote: > >> >> #code2 >> //create an instance of gpio41 >> //set direction as OUT >> //set value as 1 >> usleep(100000); >> //set value 0 >> >> Output : Toggle doesnt happens >> >> Whats this ? This is not code. At best it's comments, and usleep(). >> >> >> On Wed, Jul 13, 2016 at 9:02 PM, Raulp <[email protected] >> <javascript:>> wrote: >> >>> OK let em explain a bit more : >>> #code 1 >>> sudo echo 41 > export >>> cd gpio41 >>> sudo chmod 666 direction >>> sudo chmod 666 value >>> sudo echo out > direction >>> sudo echo 1 > value >>> sleep 1 >>> sudo echo 0 > value >>> >>> Output : Toggle on the GPIO 41 >>> >>> >>> #code2 >>> //create an instance of gpio41 >>> //set direction as OUT >>> //set value as 1 >>> usleep(100000); >>> //set value 0 >>> >>> Output : Toggle doesnt happens >>> >>> >>> Now the output I am referring to is the functioning of the hardware I >>> have used.(ignore toggling , it happens anyway using the code#2) >>> >>> >>> Or does your code simply open, and use the file descriptors without >>> any error checking what so ever ? >>> >> I dont use error codes to check , but I have seen in the oscilloscope >>> that the signal transition is happening according to my code. >>> >>> -Rp >>> >>> >>> On Wednesday, July 13, 2016 at 8:52:30 PM UTC+5:30, William Hermans >>> wrote: >>>> >>>> When I try to do the same using a user space C application I dont get >>>>> the expected response.I am running this app as sudo'er and I have >>>>> oscilloscope'd the timings of HIGH/LOW levels of the GPIOs and compared >>>>> it >>>>> with that of the manually writing procedure of GPIOS. The waveform and >>>>> the >>>>> timing diagrams almost matches (95%) >>>>> >>>> >>>> I'm not exactly sure what you saying here . . . However, in code are >>>> you actually checking for errors, and error codes. Or does your code >>>> simply >>>> open, and use the file descriptors without any error checking what so >>>> ever >>>> ? >>>> >>>> Seeing the code would probably help a lot. >>>> >>>> On Wed, Jul 13, 2016 at 2:41 AM, Raulp <[email protected]> wrote: >>>> >>>>> I have interfaced a hardware using the 5 Gpios on BBB.I can talk to >>>>> this device using GPIOs by manually (echoing 0 and 1 to the GPIOS) >>>>> writing >>>>> to it in the sys/class/gpio directory by first exporting the Gpios and >>>>> configuring their directions and value.It works perfectly fine. >>>>> But, >>>>> When I try to do the same using a user space C application I dont get >>>>> the expected response.I am running this app as sudo'er and I have >>>>> oscilloscope'd the timings of HIGH/LOW levels of the GPIOs and compared >>>>> it >>>>> with that of the manually writing procedure of GPIOS. The waveform and >>>>> the >>>>> timing diagrams almost matches (95%) >>>>> So, >>>>> What could mysteriously be missing here.?I can go deep into analyzing >>>>> the wave-forms and timing diagrams as well if there is an issue in the >>>>> timings of the Signals. >>>>> Please advice.Thanks in advance ! >>>>> -Rp >>>>> >>>>> -- >>>>> For more options, visit http://beagleboard.org/discuss >>>>> --- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "BeagleBoard" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send >>>>> an email to [email protected]. >>>>> To view this discussion on the web visit >>>>> https://groups.google.com/d/msgid/beagleboard/cb65b710-203e-4579-8c08-e2b817dc7a03%40googlegroups.com >>>>> >>>>> <https://groups.google.com/d/msgid/beagleboard/cb65b710-203e-4579-8c08-e2b817dc7a03%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>> . >>>>> For more options, visit https://groups.google.com/d/optout. >>>>> >>>> >>>> -- >>> For more options, visit http://beagleboard.org/discuss >>> --- >>> You received this message because you are subscribed to the Google >>> Groups "BeagleBoard" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected] <javascript:>. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/beagleboard/521956ed-983d-49b9-85f2-62e269dcf7fa%40googlegroups.com >>> >>> <https://groups.google.com/d/msgid/beagleboard/521956ed-983d-49b9-85f2-62e269dcf7fa%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> > -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/68d794b1-fdd4-49de-acd0-30923269f437%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
#include<iostream>
#include<unistd.h> //for usleep
#include<string.h>
#include"GPIO.h"
#define CON1 23
#define CON2 112
#define CON3 67
#define DATA1 32
#define DATA2 14
#define ms_delay_1 50000
#define ms_delay_2 50000
using namespace exploringBB;
using namespace std;
GPIO outGPIO_CON2 (CON2), outGPIO_CON3 (CON3), outGPIO_DATA1 (DATA1);
GPIO inGPIO_DATA2 (DATA2), outGPIO_CON1 (CON1);
main (int argc, char *argv[])
{
cout << "TX--->COMMAND(2)" << endl;
outGPIO_CON1.setDirection (OUTPUT);
outGPIO_CON1.setValue (LOW);
//usleep (ms_delay_1);
cout << "TX--->COMMAND(3)" << endl;
outGPIO_CON1.setValue (HIGH);
usleep (ms_delay_2);
cout <<
"TX--->WRITE_DATA(2130)-"
<< endl;
outGPIO_CON2.setDirection (OUTPUT); //112
// outGPIO_CON1.setDirection (OUTPUT); //23
outGPIO_DATA1.setDirection (OUTPUT); //32
outGPIO_CON3.setDirection (OUTPUT); //67
inGPIO_DATA2.setDirection (INPUT); //14
//write 2(0010)
cout << "TX--->WRITE_DATA(2130)----------->TX 2" << endl;
outGPIO_CON2.setValue (LOW);
usleep (ms_delay_2);
outGPIO_CON3.setValue (HIGH);
usleep (ms_delay_2);
outGPIO_CON3.setValue (LOW);
usleep (ms_delay_1);
outGPIO_CON2.setValue (LOW);
usleep (ms_delay_2);
outGPIO_CON3.setValue (HIGH);
usleep (ms_delay_2);
outGPIO_CON3.setValue (LOW);
usleep (ms_delay_1);
outGPIO_CON2.setValue (HIGH);
usleep (ms_delay_2);
outGPIO_CON3.setValue (HIGH);
usleep (ms_delay_2);
outGPIO_CON3.setValue (LOW);
usleep (ms_delay_1);
outGPIO_CON2.setValue (LOW);
usleep (ms_delay_2);
outGPIO_CON3.setValue (HIGH);
usleep (ms_delay_2);
outGPIO_CON3.setValue (LOW);
usleep (ms_delay_1);
//write 1(0001)
cout << "TX--->WRITE_DATA(2130)----------->TX 1" << endl;
outGPIO_CON2.setValue (LOW);
usleep (ms_delay_2);
outGPIO_CON3.setValue (HIGH);
usleep (ms_delay_2);
outGPIO_CON3.setValue (LOW);
usleep (ms_delay_1);
outGPIO_CON2.setValue (LOW);
usleep (ms_delay_2);
outGPIO_CON3.setValue (HIGH);
usleep (ms_delay_2);
outGPIO_CON3.setValue (LOW);
usleep (ms_delay_1);
outGPIO_CON2.setValue (LOW);
usleep (ms_delay_2);
outGPIO_CON3.setValue (HIGH);
usleep (ms_delay_2);
outGPIO_CON3.setValue (LOW);
usleep (ms_delay_1);
outGPIO_CON2.setValue (HIGH);
usleep (ms_delay_2);
outGPIO_CON3.setValue (HIGH);
usleep (ms_delay_2);
outGPIO_CON3.setValue (LOW);
usleep (ms_delay_1);
outGPIO_DATA1.setValue (HIGH);
usleep (ms_delay_1);
//write 3(0011)
cout << "TX--->WRITE_DATA(2130)----------->TX 3" << endl;
outGPIO_CON2.setValue (LOW);
usleep (ms_delay_2);
outGPIO_CON3.setValue (HIGH);
usleep (ms_delay_2);
outGPIO_CON3.setValue (LOW);
usleep (ms_delay_1);
outGPIO_CON2.setValue (LOW);
usleep (ms_delay_2);
outGPIO_CON3.setValue (HIGH);
usleep (ms_delay_2);
outGPIO_CON3.setValue (LOW);
usleep (ms_delay_1);
outGPIO_CON2.setValue (HIGH);
usleep (ms_delay_2);
outGPIO_CON3.setValue (HIGH);
usleep (ms_delay_2);
outGPIO_CON3.setValue (LOW);
usleep (ms_delay_1);
outGPIO_CON2.setValue (HIGH);
usleep (ms_delay_2);
outGPIO_CON3.setValue (HIGH);
usleep (ms_delay_2);
outGPIO_CON3.setValue (LOW);
usleep (ms_delay_1);
//write 0(0000)
cout << "TX--->WRITE_DATA(2130)----------->TX 0" << endl;
outGPIO_CON2.setValue (LOW);
usleep(ms_delay_2);
outGPIO_CON3.setValue (HIGH);
usleep (ms_delay_2);
outGPIO_CON3.setValue (LOW);
usleep (ms_delay_1);
cout << "End ...." << endl;
while (1);
}
code.bash
Description: Binary data
GPIO.7z
Description: application/7z-compressed
