2

I have a project where I got a little stuck. I use a Beaglebones PRU (like a little microcontroller) to read sensordata and write it in to a defined space of the ram. The main processor, which shares the same RAM, can then read the data. The main processor runs Linux.

I would like to timestamp the data as precisely as possible on the PRU. Is it possible to read a time-variable (like in the variable i get with "gettimeofday(..)") from Linux directly off of the ram on to the PRU? Or is there a variable for Systemticks which I can convert? How can I accomplish this the easiest way?

En Kt
  • 113
  • 1
  • 1
  • 5
  • OP seems to be confused between Raspberry Pi and Beaglebone Black – Thomas Dickey Nov 16 '15 at 00:36
  • 2
    @ThomasDickey, I suspect the OP simply missspelled [PRU](http://beagleboard.org/pru). – ghoti Nov 16 '15 at 00:57
  • That seems plausible. – Thomas Dickey Nov 16 '15 at 01:17
  • I'm failing to understand the question, there is a micro-controller a ram and a processor correct? If so and assuming the ram is the one that already comes with Beaglebone, how does the 2nd processor connects to that RAM? Assuming RPU is PRU – PeCosta Nov 16 '15 at 01:26
  • 1
    If you use c for programming you could see at https://aufather.wordpress.com/2010/09/08/high-performance-time-measuremen-in-linux/ which gives you nanosecond precision. For linux commandline see http://stackoverflow.com/questions/16548528/linux-command-to-get-time-in-milliseconds – Alexander Baltasar Nov 16 '15 at 06:37
  • So sorry that I confused PRU with RPU. I was already a little bit tired when wrote this post. Here ist short explanation of the PRU: http://beagleboard.org/pru Both the PRU and the Main-processor share the same RAM, here is an example of how they can communicate with each other: http://exploringbeaglebone.com/chapter13/ – En Kt Nov 16 '15 at 07:11
  • 1
    Have you tried looking at the IEP part of the PRU (chapter 9 in the PRU reference guide)? It contains a 32-bit timer running at 200 MHz (so 5ns granularity). Depending on the accuracy you need compared to the actual, absolute time, you'll need some way of synchronizing the two though. – sonicwave Nov 16 '15 at 07:17
  • Thank you for your reply sonicwave. Yes, I know about the timer but synchronizing might really be a problem. Accessing the Linux timer, if possible, would make it easier I think. – En Kt Nov 16 '15 at 08:27

1 Answers1

0

I don´t know if you have already solved this issue.

Currently I am working in a project in which I need to implement special communication protocols using PRUs and I need to store all communication transfers with their specific timestamp in order to generate communications reports to verify that everything has been carried out as expected.

To accomplish this task I have used Beaglebone Black RTC module. If you consult AM335x user reference manual, you could see a complete explanation of this module, its registers and accuracy. If you only need seconds accuracy, which is its limit, this module is perfect for you. If not, you can combine the information provided by its registers with IEP timer. The second option is a little bit more vast to be explained here. If this is your case, please tell me and I will try to provide a step-by-step guide.

To use RTC module from PRU, it could be accessed using OCP port. Here is a piece of code with which you can access RTC registers from PRUs. Then I store each value (hour, min, sec, year, month, day) in PRU0 RAM in order to make them readable from host.c program and check that I get the same value than typing date in Linux terminal.

   //************************************************************************
    // Reading RTC from PRU
    //************************************************************************

    // Author     : Pablo Alías Mateos
    // Project    : General
    // Description: 

    //**************************************************************************
    //==========================================================================

    //**************************************************************************
    //==========================================================================

    .origin 0                        
    .entrypoint START                

    //----------------------------------------------------------------------

    #define RTC_BASE_ADDRESS    0x44E3E000   
    #define RTC_SECONDS_OFFSET  0x00000000
    #define RTC_MIN_OFFSET      0x00000004
    #define RTC_HOUR_OFFSET     0x00000008
    #define RTC_DAYS_OFFSET     0x0000000C
    #define RTC_MONTH_OFFSET    0x00000010
    #define RTC_YEAR_OFFSET     0x00000014       

    //---------------------------------------------------------------------- 

    START:

    // Enable the OCP master port

    LBCO r0, c4, 4, 4        // load SYSCFG reg into r0 (use c4 const addr)
    CLR r0, r0, 4        // clear bit 4 (STANDBY_INIT)
    SBCO r0, c4, 4, 4        // store the modified r0 back at the load addr       


    MOV r0, RTC_BASE_ADDRESS
    MOV r1, 0x00000000      // base RAM0

    LBBO    r2,r0,RTC_HOUR_OFFSET,4 
    SBBO    r2,r1,0,4   

    LBBO    r2,r0,RTC_MIN_OFFSET,4  
    SBBO    r2,r1,4,4

    LBBO    r2,r0,RTC_SECONDS_OFFSET,4  
    SBBO    r2,r1,8,4

    LBBO    r2,r0,RTC_DAYS_OFFSET,4 
    SBBO    r2,r1,12,4

    LBBO    r2,r0,RTC_MONTH_OFFSET,4    
    SBBO    r2,r1,16,4

    LBBO    r2,r0,RTC_YEAR_OFFSET,4 
    SBBO    r2,r1,20,4

I hope you find this information useful,

Pablo