From ee9a31b9cba8600d0ea2e1746445916eeb46dd0d Mon Sep 17 00:00:00 2001
From: Florian Kaltenberger <florian.kaltenberger@eurecom.fr>
Date: Fri, 21 Mar 2014 18:02:22 +0000
Subject: [PATCH] calibrated version of tx_sig

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5208 818b1a75-f10b-46b9-bf7c-635c3b92a50f
---
 targets/PROJECTS/CORRIDOR/tx_sig_ca.m | 109 +++++++++++++++++++++-----
 1 file changed, 90 insertions(+), 19 deletions(-)

diff --git a/targets/PROJECTS/CORRIDOR/tx_sig_ca.m b/targets/PROJECTS/CORRIDOR/tx_sig_ca.m
index 126e32d137..d2f4efe978 100644
--- a/targets/PROJECTS/CORRIDOR/tx_sig_ca.m
+++ b/targets/PROJECTS/CORRIDOR/tx_sig_ca.m
@@ -4,19 +4,38 @@
 % card4 - card5: 10MHz, 2 channels each, s2, freq 2605 MHz
 % card6: 5MHz, 4 channels, s3, freq 771.5 MHz
 
-%load('ofdm_pilots_sync_30MHz.mat');
+load('ofdm_pilots_sync_30MHz.mat');
 
 addpath('../../../targets/ARCH/EXMIMO/USERSPACE/OCTAVE')
 limeparms;
 
 num_cards = oarf_get_num_detected_cards;
 
+card_select = [1 1 1 1 1 1 1];
+
 % common parameters
   rf_local= rf_local*[1 1 1 1];
   rf_rxdc = rf_rxdc*[1 1 1 1];
   rf_vcocal=rf_vcocal_19G*[1 1 1 1];
 
+tx_gain_all = [10 0 0 0;
+		  10 0 0 0;
+		  15 0 0 0;
+		  12 0 0 0;
+		  1 0 0 0;
+                  0 10 10 0;
+		  9 8 0 0];
+%tx_gain_all = [11 0 0 0;
+%		  8 0 0 0;
+%		  14 0 0 0;
+%		  13 0 0 0;
+%		  5 3 0 0;
+ %                 13 13 0 0;
+%		  0 0 0 0];
+
+
 for card=0:min(3,num_cards-1)
+  disp(card)
   % card 0-3: 20MHz
   active_rf = [1 0 0 0];
   autocal = [1 1 1 1];
@@ -26,7 +45,7 @@ for card=0:min(3,num_cards-1)
   rf_mode = rf_mode+((DMAMODE_RX+DMAMODE_TX)*active_rf);
   freq_rx = 2590e6*active_rf;
   freq_tx = freq_rx;
-  tx_gain = 10*active_rf; %[1 1 1 1];
+tx_gain = tx_gain_all(card+1,:);
   rx_gain = 0*active_rf; %1 1 1 1];
 
   eNBflag = 0;
@@ -37,15 +56,17 @@ for card=0:min(3,num_cards-1)
   else
     syncmode = SYNCMODE_SLAVE;
   end
+  %syncmode = SYNCMODE_FREE;
   rffe_rxg_low = 31*active_rf; %[1 1 1 1];
   rffe_rxg_final = 63*active_rf; %[1 1 1 1];
   rffe_band = B19G_TDD*active_rf; %[1 1 1 1];
-  oarf_config_exmimo(card,freq_rx,freq_tx,tdd_config,syncmode,rx_gain,tx_gain,eNBflag,rf_mode,rf_rxdc,rf_local,rf_vcocal,rffe_rxg_low,rffe_rxg_final,rffe_band,autocal,resampling_factor)
+oarf_config_exmimo(card,freq_rx,freq_tx,tdd_config,syncmode,rx_gain,tx_gain,eNBflag,rf_mode,rf_rxdc,rf_local,rf_vcocal,rffe_rxg_low,rffe_rxg_final,rffe_band,autocal,resampling_factor);
 end
 
-for card=4:min(5,num_cards-1)
-  % card 4-5: 10MHz
-  active_rf = [1 1 0 0];
+for card=5:min(5,num_cards-1)
+  disp(card)
+  % card 5: 10MHz
+  active_rf = [0 1 1 0];
   autocal = [1 1 1 1];
   resampling_factor = [1 1 1 1];
 
@@ -53,38 +74,65 @@ for card=4:min(5,num_cards-1)
   rf_mode = rf_mode+((DMAMODE_RX+DMAMODE_TX)*active_rf);
   freq_rx = 2605e6*active_rf;
   freq_tx = freq_rx;
-  tx_gain = 13*active_rf; %[1 1 1 1];
+tx_gain = tx_gain_all(card+1,:);
   rx_gain = 0*active_rf; %1 1 1 1];
   eNBflag = 0;
   tdd_config = DUPLEXMODE_FDD + TXRXSWITCH_TESTTX; 
   %tdd_config = DUPLEXMODE_FDD + TXRXSWITCH_LSB;
   syncmode = SYNCMODE_SLAVE;
+  %syncmode = SYNCMODE_FREE;
   rffe_rxg_low = 31*active_rf; %[1 1 1 1];
   rffe_rxg_final = 63*active_rf; %[1 1 1 1];
   rffe_band = B19G_TDD*active_rf; %[1 1 1 1];
-  oarf_config_exmimo(card,freq_rx,freq_tx,tdd_config,syncmode,rx_gain,tx_gain,eNBflag,rf_mode,rf_rxdc,rf_local,rf_vcocal,rffe_rxg_low,rffe_rxg_final,rffe_band,autocal,resampling_factor)
+oarf_config_exmimo(card,freq_rx,freq_tx,tdd_config,syncmode,rx_gain,tx_gain,eNBflag,rf_mode,rf_rxdc,rf_local,rf_vcocal,rffe_rxg_low,rffe_rxg_final,rffe_band,autocal,resampling_factor);
 end
 
 for card=6:min(6,num_cards-1)
-  % card 6: 5MHz
+  disp(card)
+  % card 6: 10MHz
+  active_rf = [1 1 0 0];
+  autocal = [1 1 1 1];
+  resampling_factor = [1 1 1 1];
+
+  rf_mode = (RXEN+TXEN+TXLPFNORM+TXLPFEN+TXLPF5+RXLPFNORM+RXLPFEN+RXLPF5+LNA1ON+LNAMax+RFBBNORM)*active_rf;
+  rf_mode = rf_mode+((DMAMODE_RX+DMAMODE_TX)*active_rf);
+  freq_rx = 2605e6*active_rf;
+  freq_tx = freq_rx;
+tx_gain = tx_gain_all(card+1,:);
+  rx_gain = 0*active_rf; %1 1 1 1];
+  eNBflag = 0;
+  tdd_config = DUPLEXMODE_FDD + TXRXSWITCH_TESTTX; 
+  %tdd_config = DUPLEXMODE_FDD + TXRXSWITCH_LSB;
+  syncmode = SYNCMODE_SLAVE;
+  %syncmode = SYNCMODE_FREE;
+  rffe_rxg_low = 31*active_rf; %[1 1 1 1];
+  rffe_rxg_final = 63*active_rf; %[1 1 1 1];
+  rffe_band = B19G_TDD*active_rf; %[1 1 1 1];
+oarf_config_exmimo(card,freq_rx,freq_tx,tdd_config,syncmode,rx_gain,tx_gain,eNBflag,rf_mode,rf_rxdc,rf_local,rf_vcocal,rffe_rxg_low,rffe_rxg_final,rffe_band,autocal,resampling_factor);
+end
+
+for card=4:min(4,num_cards-1)
+  disp(card)
+  % card 4: 5MHz
   active_rf = [1 1 1 1];
   autocal = [1 1 1 1];
   resampling_factor = [2 2 2 2];
 
-  rf_mode = (RXEN+TXEN+TXLPFNORM+TXLPFEN+TXLPF5+RXLPFNORM+RXLPFEN+RXLPF5+LNA1ON+LNAMax+RFBBNORM)*active_rf;
+  rf_mode = (RXEN+TXEN+TXLPFNORM+TXLPFEN+TXLPF25+RXLPFNORM+RXLPFEN+RXLPF25+LNA1ON+LNAMax+RFBBNORM)*active_rf;
   rf_mode = rf_mode+((DMAMODE_RX+DMAMODE_TX)*active_rf);
   freq_rx = 771.5e6*active_rf;
   freq_tx = freq_rx;
-  tx_gain = 13*active_rf; %[1 1 1 1];
+  tx_gain = tx_gain_all(card+1,:);
   rx_gain = 0*active_rf; %1 1 1 1];
   eNBflag = 0;
   tdd_config = DUPLEXMODE_FDD + TXRXSWITCH_TESTTX; 
   %tdd_config = DUPLEXMODE_FDD + TXRXSWITCH_LSB;
   syncmode = SYNCMODE_SLAVE;
+  %syncmode = SYNCMODE_FREE;
   rffe_rxg_low = 31*active_rf; %[1 1 1 1];
   rffe_rxg_final = 63*active_rf; %[1 1 1 1];
   rffe_band = B19G_TDD*active_rf; %[1 1 1 1];
-  oarf_config_exmimo(card,freq_rx,freq_tx,tdd_config,syncmode,rx_gain,tx_gain,eNBflag,rf_mode,rf_rxdc,rf_local,rf_vcocal,rffe_rxg_low,rffe_rxg_final,rffe_band,autocal,resampling_factor)
+oarf_config_exmimo(card,freq_rx,freq_tx,tdd_config,syncmode,rx_gain,tx_gain,eNBflag,rf_mode,rf_rxdc,rf_local,rf_vcocal,rffe_rxg_low,rffe_rxg_final,rffe_band,autocal,resampling_factor);
 end
 
 amp = pow2(14)-1;
@@ -92,13 +140,36 @@ s1p = 2*floor(amp*(s1./max([real(s1(:)); imag(s1(:))])));
 s2p = 2*floor(amp*(s2./max([real(s2(:)); imag(s2(:))])));
 s3p = 2*floor(amp*(s3./max([real(s3(:)); imag(s3(:))])));
 
-for card=min(6,num_cards-1):-1:6
-  oarf_send_frame(card,s3p.',16);
+%for card=min(6,num_cards-1):-1:6
+%  oarf_send_frame(card,s3p.',16);
+%end
+%for card=min(5,num_cards-1):-1:4
+%  oarf_send_frame(card,s2p.',16);
+%end
+%for card=min(3,num_cards-1):-1:0
+%  oarf_send_frame(card,s1p.',16);
+%end
+
+
+
+if card_select(7) 
+  oarf_send_frame(6,s2p(3:4,:).',16);
 end
-for card=min(5,num_cards-1):-1:4
-  oarf_send_frame(card,s2p.',16);
+if card_select(6)
+  oarf_send_frame(5,[zeros(153600,1) (s2p(1:2,:).')],16); 
 end
-for card=min(3,num_cards-1):-1:0
-  oarf_send_frame(card,s1p.',16);
+if card_select(5) 
+  oarf_send_frame(4,s3p.',16);
+end
+if card_select(4) 
+  oarf_send_frame(3,s1p(4,:).',16);
+end
+if card_select(3) 
+  oarf_send_frame(2,s1p(3,:).',16);
+end
+if card_select(2) 
+  oarf_send_frame(1,s1p(2,:).',16);
+end
+if card_select(1) 
+  oarf_send_frame(0,s1p(1,:).',16);
 end
-
-- 
GitLab