GPIO, bcm2835_gpio library Adafruit temp sensor ?!?

Discussion in 'General Programming Discussion' started by marius, Mar 25, 2014.

  1. marius

    marius New Member

    Joined:
    Mar 25, 2014
    Messages:
    8
    Likes Received:
    2
    Hi,
    Platform: ubuntu-core-12.04.4-core-armhf, board UDOO duo.

    I am strugling for a day or so to read the temperature humidity sensor SEN-10167
    using bcm2835 and Adafruit taken from RPI. Also I tried the sample rht03 from wiringPI.
    SO far looks like none of the libraries above can conrol any of the GPIO's, though
    catting echoing in /sys/.../gpio137/<> works. I tried also mimic the SEN-10167 protocol,
    in a C program reading /sys/ files back and forward, but... dealing with files io seems to slow
    to process the serial 1 bit protocol. Looks like a fopen/fread/fclose takes much more

    Total time elapsed : 214 us
    Total time elapsed : 203 us

    than 28 us for reading a bit and does not catch the timeframe to detect 1-ns and 0-es.

    Keeping the FILE* open then reading fails in all subseqent reads, returning noting, so I have
    to open-read-close.

    Any ideas how the above libraries don't conplain with
    bcm controller on UDOO, or to performe a read from gpio file under 4 uSeconds ?.

    Any other work arounds, or drivers to access the GPIO as on RPI. The bcm lib along with and Adafruit
    works simless on RPI.

    I have to do this from Linux not from ardu schetch




    Thank you.
     
  2. marius

    marius New Member

    Joined:
    Mar 25, 2014
    Messages:
    8
    Likes Received:
    2
    Solved with mmap
     
  3. ImIronman

    ImIronman New Member

    Joined:
    Mar 31, 2014
    Messages:
    8
    Likes Received:
    0
    Hello @marlus,

    Can you please explain how you solved? Am experiencing kind of similar problem over here. Also, how did you compile/execute your code? i know this might sound trivial, but am new to this area and I've absolutely no idea about how to execute a C program that manipulates GPIO on UDOO. Please help!

    Thank you!
     
  4. marius

    marius New Member

    Joined:
    Mar 25, 2014
    Messages:
    8
    Likes Received:
    2
    Ohh, I did not port the bcm2835 to UDOO-DUO.
    I need a fast way to access the GPIO's so I can implement the 1 wire RTH03 protocol.
    I enabled in kernel the GPIO memory map suport, and I am reading/writing the gpios
    accessing the memory map. I am sorry about the bcm2835, but all I need it was a gpio
    fast access. (sorry , I did not read you are new!)

    Here is the Kernel build procedure.
    You have to get the kernel: https://github.com/UDOOboard/Kernel_Unico
    Code:
    sudo apt-get install git
    git clone https://github.com/UDOOboard/Kernel_Unico
    Get the cross compiler http://udoo.org/download/files/crosscom ... abi.tar.gz
    Unzip the cross compiler in ~/CC folder, and gitting kernel creates ~/Kernel_Unico, so:

    Then at a shell prompt:

    Code:
    export CROSS_COMPILE=../CC/arm-fsl-linux-gnueabi/bin/arm-fsl-linux-gnueabi- 
    export ARCH=arm  modules
    cp ./.config ./.config-retired # backup curent config in case of screwing up
    cp ./arch/arm/configs/UDOO_defconfig  ./arch/arm/configs/UDOO_defconfig-retired  # backup UDOO config in case of screwing up
    cp ./arch/arm/configs/UDOO_defconfig ./.config  # overwrite curent config
    make xconfig  #see the attached picture, enable gpiommap, save # change it
    cp ./.config ./arch/arm/configs/UDOO_defconfig # make the USOO be what you want
    make UDOO_defconfig # not quite required in this scenario
    make  # makes the uImage and so ...
    
    You have to copy the kernel uImage from arch/arm/boot/uImage to the sdcard /boot/uImage (save the old uImage fom card in case of...)
    Now you can access the gpio's like here

    http://elinux.org/RPi_Low-level_peripherals @ GPIO Code examples



    How to: (in Ubuntu)
    get a compiler:

    Code:
    sudo apt-get install gcc
    sudo apt-get install g++
    sudo apt-get install make
    sudo apt-get install nmake
    
    As a beginer get a IDE so you dont want to write by hand Makefiles

    Code:
    sudo apt-get install codeblocks
    Read here: http://learnconlinux.blogspot.ca/ and here first
    http://www.howtoforge.com/learning-c-cp ... ep-by-step
     

    Attached Files:

  5. melko

    melko New Member

    Joined:
    Aug 9, 2014
    Messages:
    3
    Likes Received:
    0
    Hi marius,
    have you measured how fast can you read from GPIO pin using mmap?
    I'm interested since as you I need to read as fast as possible from pins, so sysfs access is not viable.
     

Share This Page