Dheeraj M Pai
/
ADF7023_iitm
for publishing
Revision 0:f22e17465b15, committed 2015-07-01
- Comitter:
- dheerajmpai23
- Date:
- Wed Jul 01 18:38:45 2015 +0000
- Commit message:
- STATUS:: Transmitting; Successful SPI interface; Data transmitting Rolling Buffer Mechanism Failed
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r f22e17465b15 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Jul 01 18:38:45 2015 +0000 @@ -0,0 +1,235 @@ +//Krishans Code using Timer + +#include "mbed.h" +#define ENDL "\r" << endl +#include<iostream> +DigitalOut led(LED_RED); +DigitalOut CS(D10); +Timer t; +float a= 0.046666666; +int i=0,j=2; +SPI adf(PTA16, PTA17, PTA15); // mosi, miso, sclk + +unsigned int data[]={0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; +void bbram_write() +{ + CS=0; + // To bring in off state + adf.write(0xB0); + wait(0.1); + CS=1; + + // Write bbram + CS=0; + adf.write(0x19); + adf.write(0x00); + adf.write(0x00); + adf.write(0x00); + + adf.write(0x00); + adf.write(0x00); + adf.write(0x00); + adf.write(0x00); + + adf.write(0x00); + adf.write(0x33); + adf.write(0x00); + adf.write(0xF4); + + adf.write(0xC2); + adf.write(0x10); + adf.write(0xC0); + adf.write(0x00); + + adf.write(0x30); + adf.write(0x31); + adf.write(0x07); + adf.write(0x00); + + adf.write(0x01); + adf.write(0x00); + adf.write(0x7F); + adf.write(0x00); + + adf.write(0x0B); + adf.write(0x37); + adf.write(0x00); + adf.write(0x00); + adf.write(0x40); + adf.write(0x0C); + adf.write(0x00); + adf.write(0x05); + adf.write(0x00); + adf.write(0x00); + adf.write(0x18); + adf.write(0x12); + adf.write(0x34); + adf.write(0x56); + adf.write(0x10); + adf.write(0x10); + adf.write(0xC4); // Different + adf.write(0x14); + adf.write(0x00); + adf.write(0x00); + adf.write(0x00); + adf.write(0x00); + adf.write(0x00); + adf.write(0x00); + adf.write(0x00); + adf.write(0x00); + adf.write(0x00); + adf.write(0x00); + adf.write(0x00); + adf.write(0x00); + adf.write(0x00); + adf.write(0x00); + adf.write(0x00); + adf.write(0x00); + adf.write(0x00); + adf.write(0x00); + adf.write(0x04); + adf.write(0x00); + adf.write(0x00); + adf.write(0x00); + adf.write(0x00); + adf.write(0x00); + CS=1; + wait(0.1); + + // Testmode register + CS=0; + adf.write(0x09); + adf.write(0x39); + adf.write(0x10); + CS=1; + wait(0.1); + + //CMD_CONFIG_DEV + CS=0; + adf.write(0xBB); + CS=1; + wait(0.1); + CS=0; + adf.write(0xFF); + adf.write(0xFF); + CS=1; + wait(0.1); +} + +void data_write() +{ + // PHY_ON + CS=0; + adf.write(0xB1); + CS=1; + wait(0.1); + CS=0; + adf.write(0xFF); + adf.write(0xFF); + CS=1; + wait(0.1); + // TRANSMIT_DATA LENGTH + CS=0; + adf.write(0x08); + adf.write(0x14); + adf.write(0xC0); + CS=1; + wait(0.1); + CS=0; + adf.write(0x08); + adf.write(0x15); + adf.write(0x01); + CS=1; + wait(0.1); + // TX_BASE ADDRESS + CS=0; + adf.write(0x09); + adf.write(0x24); + adf.write(0x20); + CS=1; + wait(0.1); + // BUFFER SIZE + CS=0; + adf.write(0x09); + adf.write(0x37); + adf.write(0xE0); + CS=1; + wait(0.1); + CS=0; + adf.write(0x09); + adf.write(0x36); + adf.write(0x70); + CS=1; + wait(0.1); + // PACKET WRITE + + CS=0; + adf.write(0x18); + adf.write(0x20); + for(i=0;i<224;i++) + { + adf.write(data[i]); + cout<<"kkkkkk"<<data[i]<<ENDL; + wait_us(1); + } + CS=1; + + + + // TX MODE + CS=0; + adf.write(0xB5); + t.start(); + + CS=1; + while(1){ +// wait_us(46666); + cout<<"in while"<<ENDL; + + if(t.read_us()>=46666*(j-1)) + { +// cout<<"in if1"<<ENDL; +// cout<<"time= "<<t.read_us()<<ENDL; + cout<<t.read_us()<<ENDL; + CS=0; + if(!(j%2)) + { cout<<"in if2"<<ENDL; + adf.write(0x18); + adf.write(0x20); + } + else + { + adf.write(0x18); + adf.write(0x90); + + } + + for(i=112*j;i<112*(j+1);i++) + { + adf.write(data[i]); +// cout<<"in for i= "<<i<<"_"<<data[i]<<"_"<<t.read_us()<<ENDL; + + } + CS=1; + j++; + + if(j==4) + break; + + if(t.read()>1.3) + break; + } + } + +} + + + +int main() +{ + cout<<"in the main"<<ENDL; + bbram_write(); + cout<<"bbram written"<<ENDL; + data_write(); + +} \ No newline at end of file
diff -r 000000000000 -r f22e17465b15 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Jul 01 18:38:45 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/7cff1c4259d7 \ No newline at end of file