Thursday, July 21, 2016

(Firmware) SPI using GPIO : The code

#ifndef __SPI__H__
#define __SPI__H__

extern unsigned char time_y = 8;

void SPI_Master_GPIO_Init(void)
{
PC_DDR|=(1<<6 mosi="" nbsp="" span="">
PC_CR1|=(1<<6 span="">
PC_CR2&=~(1<<6 span="">

PC_DDR|=(1<<5 nbsp="" span="">
PC_CR1|=(1<<5 span="">
PC_CR2&=~(1<<5 span="">

PA_DDR|=(1<<3 nbsp="" out="" span="">
PA_CR1|=(1<<3 span="">
PA_CR2&=~(1<<3 span="">

PC_DDR&=~(1<<7 in="" miso="" nbsp="" span="">
PC_CR1|=(1<<7 span="">
PC_CR2&=~(1<<7 span="">
}

void CSN_low (void)
{
PA_ODR &= ~(1<<3 span="">
}

void CSN_high (void)
{
PA_ODR |= (1<<3 span="">
}


void SPI_Slave_GPIO_Init(void)
{
PC_DDR&=~(1<<6 span="">
PC_CR1|=(1<<6 span="">
PC_CR2&=~(1<<6 span="">

PC_DDR&=~(1<<5 span="">
PC_CR1|=(1<<5 span="">
PC_CR2&=~(1<<5 span="">

PA_DDR&=~(1<<3 span="">
PA_CR1|=(1<<3 span="">
PA_CR2&=~(1<<3 span="">

PC_DDR|=(1<<7 span="">
PC_CR1|=(1<<7 span="">
PC_CR2&=~(1<<7 span="">
}




void send_char (unsigned int temp)
{
unsigned char j = 0, i = 0;

for(i=0;i<8 i="" span="">
{

j = 7-i;
PC_ODR &= ~(1<<5 span="">

if((temp>>j) & 0x01)
PC_ODR |= (1<<6 span="">
else
PC_ODR &= ~(1<<6 span="">

time_y = 8;
 while(time_y--);
PC_ODR |= (1<<5 span="">
 time_y = 8;
 while(time_y--);
PC_ODR &= ~(1<<5 span="">
}

}




unsigned char get_char (void)
{
unsigned char j = 0, i = 0;

for(i=0;i<8 i="" span="">
{
unsigned char k = 7-i;

PC_ODR &= ~(1<<5 span="">



time_y = 8;
 while(time_y--);
PC_ODR |= (1<<5 span="">

if(PC_IDR & (1<<7 span="">
{
j |= (1<
 }
else
time_y = 8;
 while(time_y--);
PC_ODR &= ~(1<<5 span="">

}
return j;

}

void write_n_byte (unsigned char add,unsigned char no_of_byte,unsigned char *string_data)
{
unsigned char i = 0;
add |=0x20;
send_char(add);
for (i = 0; i < no_of_byte ; i++)
{
send_char(*string_data+i);
}
}








#endif

Saturday, March 5, 2016

RF modules


A comparison among various available RF module/IC :-
Part No.
Tx - Power (dBm)
Rx - Power (dBm)
Current consumption (mA)
Range (m)
Data Transmission rate
Operating Frequency (MHz)
Price
(Rupees)
Protocol supported
Special Feature
RFM22/3B
+20/+13
-121
85/30  18.5
600
256 KBPS
ISM band
800 (module)
RF
LBD & TS
SPIRIT 1
+11/+16
-118
21      9
200
500 KBPS
ISM band
160 (IC)
RF
LBD & TS
Carrier sns
whitening
TC32306FTG
+10
-116
12      9.7
00

ISM band
300(IC)
RF

LE-50-433/868
14
-109
45     26
2000
115.2 KBPS
ISM band

RF

nRF24L01+
0
-82
-85
-94
11.3   13.5
50
2 MBPS
1 MBPS
250 KBPS
ISM band
250
RF

MRF89XAM9A
+10
-105
-111
25      3
100
25 KBPS
2 KBPS
ISM band
500(module)
RF

SiFLEX02-R2
24
-102
285     30
3200
40 KBPS
900 MHz
3000(module)
RF  &
Zigbee
With antenna
TarangF4L
0
-92
45      50

250 KBPS
ISM band

RF  &
Zigbee
With antenna
Xbee


45      50
30
~250 KBPS
ISM band
1000(module)
Zigbee

MDBT40
+4
-93
16     12.6
80
250 KBPS
ISM band
500(module)
BLE

nRF51422
+4
-93
10.5    13
100
2 MBPS
ISM band
1000 (module)
BLE

HC06
+6
-80
40     30
50
2 MBPS
ISM band
300(module)
BLE

EMB-TRX169PA
+27
-122
385    27
>500
200 KBPS
169 MHz
(module)
RF
External antenna rqd
LBD : Low Battery Detection
TS  : Temperature Sensor