Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] CC1100 read/write register problem?

Status
Not open for further replies.

Gigica

Newbie level 3
Joined
Aug 22, 2007
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,317
I am trying to read/write config registers in cc1100 as a first step to make RF communication but without success. Using ATmega8515 and code almost identical to this in next link but for AVR , not for PIC like in this example.

After reset I read the folowing config registers which are not default values for CC1100 , (1. problem) :
Addr. 0x00 : 0x00
Addr. 0x01 : 0x18
Addr. 0x02 : 0x3E
Addr. 0x03 : 0x06
Addr. 0x04 : 0x88
Addr. 0x05 : 0x00
Addr. 0x06 : 0xFE
Addr. 0x07 : 0x00
Addr. 0x08 : 0x00
Addr. 0x09 : 0x00
Addr. 0x0A : 0x00
Addr. 0x0B : 0x0E
Addr. 0x0C : 0x00
Addr. 0x0D : 0x1C
Addr. 0x0E : 0x80
Addr. 0x0F : 0xD0
Addr. 0x10 : 0x10
Addr. 0x11 : 0x00
Addr. 0x12 : 0x00
Addr. 0x13 : 0x00
Addr. 0x14 : 0xF0
Addr. 0x15 : 0x0C
Addr. 0x16 : 0x06
Addr. 0x17 : 0x20
Addr. 0x18 : 0x00
Addr. 0x19 : 0x68
Addr. 0x1A : 0x50
Addr. 0x1B : 0x02
Addr. 0x1C : 0x00
Addr. 0x1D : 0x00
Addr. 0x1E : 0x0C
Addr. 0x1F : 0x48
Addr. 0x20 : 0xF0
Addr. 0x21 : 0x10
Addr. 0x22 : 0x00
Addr. 0x23 : 0x00
Addr. 0x24 : 0x00
Addr. 0x25 : 0x00
Addr. 0x26 : 0x08
Addr. 0x27 : 0x00
Addr. 0x28 : 0x00
Addr. 0x29 : 0x20
Addr. 0x2A : 0x7E
Addr. 0x2B : 0x3E
Addr. 0x2C : 0x00
Addr. 0x2D : 0x20
Addr. 0x2E : 0x04

Second problem is that I cannot write to registers what I want and where I want . Some examples are when write to 0x03 register , value 0xBC , I read that value from config reg 0x01 etc. Some values seemed not to be written at all .
As from hardware Atmega8515 is connected to SPI lines of CC1100 via multiplexer and level translator that makes delay max 200ns that should not be problem .
The same results I got when spi avr module is used instead of spi-like software functions which are almost identical with those in link above .
Here are code snippets , most important :

Code:
[CODE]/////////////////////////////
#define SCK PORTB.7 //is connected to SCLK of CC1100
#define SI PINB.6  //is connected to SO of CC1100
#define SO PORTB.5 //is connected to SI of CC1100
#define CS PORTB.4  //is connected to CSn of CC1100

///SPI Based CC1100 Tranceiver module//////////////////////////////////////////
#define WRITE_SINGLE 0x00 //
#define WRITE_BURST 0x40 // || R/W- , B , AD5-AD0 ||
#define READ_SINGLE 0x80 //
#define READ_BURST 0xC0 //
///////////////////////////////////////////////////////////////////////////////
unsigned char AD_SPI_write(unsigned char content)
{
unsigned char status=0x00;
unsigned char value=0x00,i;
SCK=0; //In IDLE clock should be 0

for(i=0;i<8;i++)
{
 value=(content & 0x80);
 if(value!=0x00) //checking each bits
 {
 //SCK=0;
 SO=1;
 }
 else
 {
 //SCK=0;
 SO=0;
 }
#asm("nop");
#asm("nop");
#asm("nop");
#asm("nop");
#asm("nop");
#asm("nop");
#asm("nop");
#asm("nop");
SCK=1; //clock from L to H
#asm("nop");
#asm("nop");
#asm("nop");
#asm("nop");
content=content<<1; //shifting for next bit
status=status<<1;
if(SI==1)
{
status=status|0x01;
}
else if(SI==0)
{
status=status&0xFE;
}
#asm("nop");
#asm("nop");
#asm("nop");
#asm("nop");
SCK=0;
}
SO=0;
return status;
}
//////////////////////////////////////////////////////////////////////////////
unsigned char AD_SPI_read(void)
{
unsigned char i=0;
unsigned char content=0x00;
SCK=0;
for(i=0;i<8;i++)
{
content=content<<1;
SCK=1;
if(SI==1)
{
content=content|0x01;
}
else if(SI==0)
{
content=content&0xFE;
}
#asm("nop");
#asm("nop");
#asm("nop");
#asm("nop");
#asm("nop");
#asm("nop");
#asm("nop");
#asm("nop");
SCK=0;
#asm("nop");
#asm("nop");
#asm("nop");
#asm("nop");
}
SCK=0;
SO=0; //default position
//CS=1; //
return content;
}
///////////////////////////////////////////////////////////////////////////////
////////////////////////END of SPI Functions///////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
unsigned char AD_CC1100_read_REG(unsigned char address)
{
unsigned char value;
address|=READ_SINGLE;
CS=1;
SCK=0; //jst to be sure
CS=0;
while(SI); //Wait for SI to become zero
AD_SPI_write(address);
delay_us(10); //A min 100ns delay bw each access
value=AD_SPI_read();
SCK=0;
//SI=1;
SO=0; //default position
CS=1; //
return value;
}
///////////////////////////////////////////////////////////////////////////////
void AD_CC1100_write_REG(unsigned char address, unsigned char value)
{
//unsigned char value;
CS=1;
SCK=0;
SCK=1;
SCK=0;
SCK=1;
SCK=0;
address|=WRITE_SINGLE;
CS=0;
while(SI);
AD_SPI_write(address);
delay_us(10);
AD_SPI_write(value);
SCK=0;
SO=0;
CS=1;
}
/////////////////////////////////////////////////////////////////////////////// 
unsigned char AD_CC1100_POWERUP(void)
{
unsigned status=0xFF; // For debug to be deleated
CS=1; //default state
SCK=1;
SO=0;
CS=0;
delay_ms(5);
CS=1;
delay_ms(5);
CS=0;

CS=1;
status=AD_CC1100_command_STROBE(CC1100_SRES);
}
void main(void)
{
  Port B initialization
// Func7=Out Func6=In Func5=Out Func4=Out Func3=In Func2=In Func1=In Func0=In 
// State7=0 State6=T State5=0 State4=0 State3=T State2=T State1=T State0=T 
PORTB=0x00; 
DDRB=0xB0;
CS=1; //default state
SCK=0;
SO=0; 

delay_ms(100); 
AD_CC1100_POWERUP();
while (1)
      {
        //...
        //reading conf registers and send them to UART
        for(regCounter = 0x00; regCounter <= 0x2E; regCounter++) 
               {
                printf ("Addr. 0x%02X : ",regCounter);
                printf ("0x%02X\n\r",AD_CC1100_read_REG(regCounter));
               }
         //...
         //write to conf register
         AD_CC1100_write_REG(tempReg,dataReg);
          printf("\n\r%2x written in %2x",dataReg,tempReg);
       }
}
[/CODE]

Need help as soon as possible !
 

Gigica

Newbie level 3
Joined
Aug 22, 2007
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,317
The problem in my design was in hardware , ie. in multiplexer which on my developement system has some hanging pins . When I put some pull-ups , everything worked !
Another proof software that Mr. Joe333 has given , works !
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top