hi,

I am not really familiarise with assembler. I have a beagle bone black, i 
followed several examples that I found in internet regarding how to use pwm 
with PRU ports and it works properly in my BBB.

As I said I am not familiarise with assembler and PRU. I wonder if anybody 
could help me on that. I need to use 4 pwm and 4 AI in beagle bone, but I 
donĀ“t know exactly how to do it. I wonder if you could modificate pwm.c and 
pwm.p  to use these signals and also BB-BONE-PRU-00A0.dts

I will really appreciate it if you can help me on that, because i am not 
sure if i should copy paste the same code several times or create a bucle 
to get the mod efficient way.

thank you so much and sorry for the inconveniences

regards

*1) *BB-BONE-PRU-00A0.dts

> /*
>
> * pru dts file BB-BONE-PRU-00A0.dts
>
> */
>
> /dts-v1/;
>
> /plugin/;
>
>  
>
> / {
>
>   compatible = "ti,beaglebone", "ti,beaglebone-black";
>
>  
>
>   /* identification */
>
>   part-number = "BB-BONE-PRU";
>
>   version = "00A0";
>
>   exclusive-use =
>
>     "P8.12";
>
>  
>
>   fragment@0 {
>
>     target = <&am33xx_pinmux>;
>
>     __overlay__ {
>
>       mygpio: pinmux_mygpio{
>
>         pinctrl-single,pins = <
>
>           0x30 0x06
>
>           >;
>
>       };
>
>     };
>
>   };
>
>  
>
>   fragment@1 {
>
>     target = <&ocp>;
>
>     __overlay__ {
>
>       test_helper: helper {
>
>         compatible = "bone-pinmux-helper";
>
>         pinctrl-names = "default";
>
>         pinctrl-0 = <&mygpio>;
>
>         status = "okay";
>
>       };
>
>     };
>
>   };
>
>  
>
>   fragment@2{
>
>   target = <&pruss>;
>
>     __overlay__ {
>
>       status = "okay";
>
>     };
>
>   };
>
> };
>
>
>

*2) *mytest.c

 

>
>> /******************************************************************************
>>  
>
> * Include Files * 
>
>
>> ******************************************************************************/
>>  
>
> // Standard header files
>
> #include <stdio.h> 
>
> #include <stdlib.h> 
>
> #include <sys/mman.h> 
>
> #include <fcntl.h> 
>
> #include <errno.h> 
>
> #include <unistd.h> 
>
> #include <string.h> 
>
> //#include <math.h>
>
> // Driver header file
>
> #include "prussdrv.h"
>
> #include <pruss_intc_mapping.h>  
>
> #include <math.h>
>
>
>>
>> /******************************************************************************
>>  
>
> * Local Macro Declarations * 
>
>
>> ******************************************************************************/
>
> #define PRU_NUM   0     
>
>
>> int main(void){
>
>
>> unsigned int ret;
>
> unsigned int i,value;
>
>
>> tpruss_intc_initdata pruss_intc_initdata = PRUSS_INTC_INITDATA;
>
> printf("\nINFO: Starting %s example.\r\n", "PWM Demo with PRU");
>
> // Initialize the PRU 
>
> prussdrv_init();
>
> // Open PRU Interrupt 
>
> ret = prussdrv_open(PRU_EVTOUT_0);
>
> if (ret)
>
> {
>
> printf("prussdrv_open open failed\n");
>
> return (ret);
>
> }
>
>
>> // Get the interrupt initialized
>
> prussdrv_pruintc_init(&pruss_intc_initdata);
>
>
>> //Execute example on PRU
>
> printf("\tINFO: Executing example.\r\n");
>
> prussdrv_exec_program(PRU_NUM, "./mytest.bin");
>
>         for (i = 0; i < 100000; i++) {
>
>                 usleep(100);
>
> value=(sin(i*0.01)+1)*120+5;
>
> prussdrv_pru_write_memory(PRUSS0_PRU0_DATARAM, 0x00000040, &value, 
>> sizeof(unsigned int));
>
> printf("(%d)\n-> ",value);
>
>         }
>
>
>>
>>         // Wait until PRU0 has finished execution
>
>         printf("\tINFO: Waiting for HALT command.\r\n");
>
>  prussdrv_pru_wait_event(PRU_EVTOUT_0);
>
> printf("\tINFO: PRU completed transfer.\r\n");
>
> prussdrv_pru_clear_event(PRU0_ARM_INTERRUPT);
>
>
>> // Disable PRU and close memory mapping
>
> prussdrv_pru_disable(PRU_NUM);
>
> prussdrv_exit();
>
> return(0);
>
> }
>
>
>>
*3) mytest.p*

.origin 0
>
> .entrypoint START
>
>
>> #include "mytest.hp"
>
>
>> #define GPIO1 0x4804c000
>
> #define GPIO_CLEARDATAOUT 0x190
>
> #define GPIO_SETDATAOUT 0x194
>
> #define MEM_START 0x00000100
>
>
>> START:
>
> //set ARM such that PRU can write to GPIO
>
> LBCO r0, C4, 4, 4
>
> CLR r0, r0, 4
>
> SBCO r0, C4, 4, 4
>
>
>>
>>
>> CLR r30.t14
>
> SET r30,14
>
>
>> //for(r0=0x0100000;r0>0;ro--){
>
> MOV r0,0x01000000
>
>
>>
>> LOOP1:
>
>   CLR r30.t14 //clear pin GPIO1_12
>
>
>>           MOV r18, MEM_START
>
>           LBBO r1, r18, 0, 4
>
>           AND r1, r1, 0x000000FF
>
> DELAY2:   SUB r1, r1 , 1 //if r1=100 =>delay 1us
>
>   QBNE DELAY2, r1, 0 
>
>
>>           SET r30,14 //set pin GPIO44
>
>           MOV r18, MEM_START
>
>           LBBO r1, r18, 0, 4
>
>   AND r1, r1, 0x000000FF
>
>   MOV r2, 0x00000100
>
>   RSB r1, r1, r2
>
> DELAY3:   SUB r1, r1 , 1
>
>           QBNE DELAY3, r1, 0
>
>
>>   SUB r0, r0, 1
>
>   QBNE LOOP1, r0, 0
>
>  
>
>
>>
>>           MOV r31.b0, PRU0_ARM_INTERRUPT+16  //tell the c program we are 
>> done 
>
> //(just remove it if your c program does not handle the interrupt)
>
>           HALT      // Halt the processor
>
>

-- 
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 beagleboard+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to