changeset 26:6d64ee8c0754 matrix_gpio

- fixed bug that caused the PRU to hang when opening a socket or an ssh connection. Bug was a typo in LBBO reg_gpio2_oe
author Giulio Moro <giuliomoro@yahoo.it>
date Sun, 10 May 2015 01:33:16 +0100
parents 182ae9367104
children 06fd2ffee605
files include/pru_rtaudio_bin.h pru_rtaudio.bin pru_rtaudio.p
diffstat 3 files changed, 26 insertions(+), 70 deletions(-) [+]
line wrap: on
line diff
--- a/include/pru_rtaudio_bin.h	Tue May 05 17:28:00 2015 +0100
+++ b/include/pru_rtaudio_bin.h	Sun May 10 01:33:16 2015 +0100
@@ -5,7 +5,7 @@
 /* This file is generated by the PRU assembler.                       */
 
 const unsigned int PRUcode[] =  {
-     0x7b00002e,
+     0x7b00000e,
      0x244804c2,
      0x24c13482,
      0xf1002282,
@@ -79,7 +79,7 @@
      0xe1002382,
      0x24481ac3,
      0x24c13483,
-     0xf1002283,
+     0xf1002383,
      0x240000e5,
      0x240000e4,
      0xd100fb07,
@@ -172,134 +172,102 @@
      0x24c13883,
      0xf1002282,
      0xf1002383,
-     0xc904fb07,
-     0x1f0efefe,
+     0xc904fb06,
      0xc90de203,
      0x1f14fbfb,
      0x79000003,
      0x1d14fbfb,
      0x79000001,
-     0x1d0efefe,
-     0xc905fb07,
-     0x1f0efefe,
+     0xc905fb06,
      0xc90ce203,
      0x1f15fbfb,
      0x79000003,
      0x1d15fbfb,
      0x79000001,
-     0x1d0efefe,
-     0xc906fb07,
-     0x1f0efefe,
+     0xc906fb06,
      0xc91ce203,
      0x1f16fbfb,
      0x79000003,
      0x1d16fbfb,
      0x79000001,
-     0x1d0efefe,
-     0xc907fb07,
-     0x1f0efefe,
+     0xc907fb06,
      0xc912e203,
      0x1f17fbfb,
      0x79000003,
      0x1d17fbfb,
      0x79000001,
-     0x1d0efefe,
-     0xc908fb07,
-     0x1f0efefe,
+     0xc908fb06,
      0xc90fe203,
      0x1f18fbfb,
      0x79000003,
      0x1d18fbfb,
      0x79000001,
-     0x1d0efefe,
-     0xc909fb07,
-     0x1f0efefe,
+     0xc909fb06,
      0xc90ee203,
      0x1f19fbfb,
      0x79000003,
      0x1d19fbfb,
      0x79000001,
-     0x1d0efefe,
-     0xc90afb07,
-     0x1f0efefe,
+     0xc90afb06,
      0xc913e203,
      0x1f1afbfb,
      0x79000003,
      0x1d1afbfb,
      0x79000001,
-     0x1d0efefe,
-     0xc900fb07,
-     0x1f0efefe,
+     0xc900fb06,
      0xc902e303,
      0x1f10fbfb,
      0x79000003,
      0x1d10fbfb,
      0x79000001,
-     0x1d0efefe,
-     0xc901fb07,
-     0x1f0efefe,
+     0xc901fb06,
      0xc903e303,
      0x1f11fbfb,
      0x79000003,
      0x1d11fbfb,
      0x79000001,
-     0x1d0efefe,
-     0xc902fb07,
-     0x1f0efefe,
+     0xc902fb06,
      0xc905e303,
      0x1f12fbfb,
      0x79000003,
      0x1d12fbfb,
      0x79000001,
-     0x1d0efefe,
-     0xc903fb07,
-     0x1f0efefe,
+     0xc903fb06,
      0xc904e303,
      0x1f13fbfb,
      0x79000003,
      0x1d13fbfb,
      0x79000001,
-     0x1d0efefe,
-     0xc90bfb07,
-     0x1f0efefe,
+     0xc90bfb06,
      0xc901e303,
      0x1f1bfbfb,
      0x79000003,
      0x1d1bfbfb,
      0x79000001,
-     0x1d0efefe,
-     0xc90cfb07,
-     0x1f0efefe,
+     0xc90cfb06,
      0xc916e303,
      0x1f1cfbfb,
      0x79000003,
      0x1d1cfbfb,
      0x79000001,
-     0x1d0efefe,
-     0xc90dfb07,
-     0x1f0efefe,
+     0xc90dfb06,
      0xc918e303,
      0x1f1dfbfb,
      0x79000003,
      0x1d1dfbfb,
      0x79000001,
-     0x1d0efefe,
-     0xc90efb07,
-     0x1f0efefe,
+     0xc90efb06,
      0xc917e303,
      0x1f1efbfb,
      0x79000003,
      0x1d1efbfb,
      0x79000001,
-     0x1d0efefe,
-     0xc90ffb07,
-     0x1f0efefe,
+     0xc90ffb06,
      0xc919e303,
      0x1f1ffbfb,
      0x79000003,
      0x1d1ffbfb,
      0x79000001,
-     0x1d0efefe,
      0x244804c2,
      0x24c19082,
      0x24481ac3,
@@ -307,7 +275,6 @@
      0xe1006287,
      0xe1006384,
      0x209c0000,
-     0x240000fe,
      0x240002c3,
      0x24202083,
      0x240000e2,
@@ -631,7 +598,6 @@
      0x240280fc,
      0x00fcfdfc,
      0xf1003c82,
-     0x1f0ffefe,
      0x10f0f0f2,
      0x2701e9e2,
      0x08e2ebf3,
@@ -649,7 +615,6 @@
      0x240001c6,
      0x24100086,
      0x00e2e6e6,
-     0x1d0ffefe,
      0x240000e1,
      0xc901f805,
      0x90f2388c,
@@ -821,7 +786,7 @@
      0x00e1e3e3,
      0xe1002382,
      0xf1003982,
-     0x5700e242,
+     0x5700e244,
      0x240000fb,
      0xe1443d9b,
      0xc901f80c,
Binary file pru_rtaudio.bin has changed
--- a/pru_rtaudio.p	Tue May 05 17:28:00 2015 +0100
+++ b/pru_rtaudio.p	Sun May 10 01:33:16 2015 +0100
@@ -274,7 +274,6 @@
 .macro READ_GPIO_BITS
 .mparam gpio_data, gpio_num_bit, digital_bit, digital
     QBBC DONE, digital, digital_bit //if the pin is set as an output, nothing to do here
-SET r30.t14
     QBBC CLEAR, gpio_data, gpio_num_bit 
     SET digital, digital_bit+16
     QBA DONE
@@ -282,7 +281,6 @@
         CLR digital, digital_bit+16
         QBA DONE
     DONE:
-CLR r30.t14
 .endm
 
 .macro SET_GPIO_BITS
@@ -330,7 +328,7 @@
 
 //load current status of GPIO_OE in reg_gpioX_oe
     MOV reg_gpio1_oe, GPIO1 | GPIO_OE 
-    //takes ...ns to go through the next two instructions
+    //it takes 190ns to go through the next instruction
     LBBO reg_gpio1_oe, reg_gpio1_oe, 0, 4
 //GPIO1-start
 //process oe and datain and prepare dataout for GPIO1
@@ -353,9 +351,9 @@
 // reg_gpio1_datain now unused, its register is taken by gpio2_setdataout
 //GPIO2-start
 //load current status of GPIO_OE in reg_gpioX_oe
-    MOV reg_gpio2_oe, GPIO2 | GPIO_OE 
-    //takes ...ns to go through the next two instructions
-    LBBO reg_gpio2_oe, reg_gpio1_oe, 0, 4
+    MOV reg_gpio2_oe, GPIO2 | GPIO_OE  
+//it takes 200ns to go through the next instructions
+    LBBO reg_gpio2_oe, reg_gpio2_oe, 0, 4
 //process oe and datain and prepare dataout for GPIO2
     LDI reg_gpio2_setdataout, 0 
     LDI reg_gpio2_cleardataout, 0
@@ -377,10 +375,9 @@
 //load current inputs in reg_gpioX_datain
     MOV reg_gpio1_datain, GPIO1 | GPIO_DATAIN 
     MOV reg_gpio2_datain, GPIO2 | GPIO_DATAIN 
-    //takes ...ns to go through the next two instructions
+    //takes 375 nns to go through the next two instructions
     LBBO reg_gpio1_datain, reg_gpio1_datain, 0, 4
     LBBO reg_gpio2_datain, reg_gpio2_datain, 0, 4
-//TODO: read inputs
     READ_GPIO1_BITS 13, 4
     READ_GPIO1_BITS 12, 5
     READ_GPIO1_BITS 28, 6
@@ -407,7 +404,7 @@
     MOV reg_gpio1_datain, GPIO1 | GPIO_CLEARDATAOUT //reg_gpio1_datain is now unused and is used here as a temp
     MOV reg_gpio2_datain, GPIO2 | GPIO_CLEARDATAOUT //reg_gpio2_datain is now unused and is used here as a temp
 //write 8 bytes for each GPIO
-//takes 30ns in total to go through the followint two lines
+//takes 30ns in total to go through the following two lines
     SBBO reg_gpio1_cleardataout, reg_gpio1_datain, 0, 8 // takes 145ns to be effective when going low, 185ns when going high
     SBBO reg_gpio2_cleardataout, reg_gpio2_datain, 0, 8 //takes 95ns to be effective when going low, 130ns when going high
 //reversing the order of the two lines above will swap the performances between the GPIO modules
@@ -571,7 +568,6 @@
 .endm
    
 START:
-      MOV r30, 0 
       // Set up c24 and c25 offsets with CTBIR register
       // Thus C24 points to start of PRU0 RAM
       MOV r3, 0x22020       // CTBIR0
@@ -784,7 +780,6 @@
 WRITE_ONE_BUFFER:
       // Write a single buffer of DAC samples and read a buffer of ADC samples
       // Load starting positions
-SET r30.t15
       MOV reg_dac_current, reg_dac_buf0         // DAC: reg_dac_current is current pointer
       LMBD r2, reg_num_channels, 1		// 1, 2 or 3 for 2, 4 or 8 channels
       LSL reg_adc_current, reg_frame_total, r2
@@ -805,7 +800,6 @@
       MOV reg_digital_current, MEM_DIGITAL_BASE
       ADD reg_digital_current, reg_digital_current, r2
 
-CLR r30.t15
 WRITE_LOOP:
       // Write N channels to DAC from successive values in memory
       // At the same time, read N channels from ADC
@@ -884,7 +878,7 @@
       ADD reg_mcasp_adc_current, reg_mcasp_adc_current, 4
 MCASP_ADC_DONE:	
       QBBC SPI_SKIP_WRITE, reg_flags, FLAG_BIT_USE_SPI
-	
+
       // DAC: transmit low word (first in little endian)
       MOV r2, 0xFFFF
       AND r7, reg_dac_data, r2
@@ -952,7 +946,6 @@
       ADD r1, r1, 1
       QBNE ADC_DAC_LOOP, r1, reg_num_channels
       QBA ADC_DAC_LOOP_DONE
-
 SPI_SKIP_WRITE:
       // We get here only if the SPI ADC and DAC are disabled
       // Just keep the loop going for McASP
@@ -1006,7 +999,6 @@
       ADD r3, r3, r1          // Address for GPIO clear register
       SBBO r2, r3, 0, 4       // Clear GPIO pin	
 LED_BLINK_DONE:	
-	
       // Check if we should finish: flag is zero as long as it should run
       LBBO r2, reg_comm_addr, COMM_SHOULD_STOP, 4
       QBEQ WRITE_ONE_BUFFER, r2, 0
@@ -1028,7 +1020,6 @@
       CLR r2, r2, 1
       SBBO r2, r3, 0, 4      
 SPI_CLEANUP_DONE:
-	
       // Signal the ARM that we have finished 
       MOV R31.b0, PRU0_ARM_INTERRUPT + 16
       HALT