Пример #1
0
void WakeUpCC1020ToRX(char RXANALOG1)
{
  // Turn on xtal oscillator core
  WriteToCC1020Register(CC1020_MAIN,0x1B);

  // Setup bias current adjustment
  WriteToCC1020Register(CC1020_ANALOG,RXANALOG1);

  // Insert wait routine here, must wait for xtal oscillator to stabilise, 
  // typically takes 2-5ms.
  //for (i=0x0260; i > 0; i--);
  _delay_ms(3);

  // Turn on bias generator
  WriteToCC1020Register(CC1020_MAIN,0x19);

  // Wait for 150 usec
  int i;
  for (i=0x0010; i > 0; i--);
  //_delay_us(150);


  // Turn on frequency synthesiser
  WriteToCC1020Register(CC1020_MAIN,0x11);
}
Пример #2
0
void SetupCC1020PD(void)
{
  // Put CC1020 into power-down
  WriteToCC1020Register(CC1020_MAIN,0x1F);
  // Turn off PA to minimise current draw
  WriteToCC1020Register(CC1020_PA_POWER,0x00);
}
Пример #3
0
void ResetCC1020(void)
{
  // Reset CC1020
  WriteToCC1020Register(CC1020_MAIN, 0x0E);
  // Bring CC1020 out of reset
  WriteToCC1020Register(CC1020_MAIN, 0x1F);
}
Пример #4
0
void WakeUpCC1020ToTX(char TXANALOG1)
{


    // Turn on xtal oscillator core
    WriteToCC1020Register(CC1020_MAIN,0xDB);

    // Setup bias current adjustment
    WriteToCC1020Register(CC1020_ANALOG,TXANALOG1);

    // Insert wait routine here, must wait for xtal oscillator to stabilise,
    // typically takes 2-5ms.
    //for (i=0x0260; i > 0; i--);
    _delay_ms(3);

    // Turn on bias generator
    WriteToCC1020Register(CC1020_MAIN,0xD9);

    // Wait for 150 usec
    for (int i=0x0010; i > 0; i--);
    //_delay_us(150);			 // Not possible, max delay using this function is 96us

    // Turn on frequency synthesiser
    WriteToCC1020Register(CC1020_MAIN,0xD1);




}
Пример #5
0
void WakeUpCC1020ToRX(char RXANALOG1)
{

  // Turn on xtal oscillator core
  WriteToCC1020Register(CC1020_MAIN,0x1B);

  // Setup bias current adjustment
  WriteToCC1020Register(CC1020_ANALOG,RXANALOG1);

  // Insert wait routine here, must wait for xtal oscillator to stabilise, 
  // typically takes 2-5ms.
  //for (i=0x0260; i > 0; i--);
	_delay_ms(3);

  // Turn on bias generator
  WriteToCC1020Register(CC1020_MAIN,0x19);
  
  x = ReadFromCC1020Register(CC1020_MAIN);
  sprintf(arr, "Read: %x\r\n", x);
  //send_UART(arr, strlen(arr));

  // Wait for 150 usec
  _delay_us(150);

  // Turn on frequency synthesiser
  WriteToCC1020Register(CC1020_MAIN,0x11);
}
Пример #6
0
char SetupCC1020RX(char RXANALOG1, char PA_POWER1)
{
    volatile int TimeOutCounter;
    char lock_status;

    // Turn ON DCLK_CS (Carrier Sense Squelch) in RX
    WriteToCC1020Register(CC1020_INTERFACE,ReadFromCC1020Register(CC1020_INTERFACE) | 0x10);


    // Switch into RX, switch to freq. reg A
    WriteToCC1020Register(CC1020_MAIN,0x11);

    // Setup bias current adjustment
    WriteToCC1020Register(CC1020_ANALOG,RXANALOG);

    // Monitor LOCK
    for(TimeOutCounter=30; ((ReadFromCC1020Register(CC1020_STATUS)&0x10)==0)&&(TimeOutCounter>0); TimeOutCounter--)
    {
        _delay_ms(1);
    }

    // If PLL in lock
    if((ReadFromCC1020Register(CC1020_STATUS)&0x10)==0x10)
    {
        lock_status = TRUE;
        sbi(PORTA,LED_PLL);
    }
    else	// Recalibrate
    {
        // If recalibration ok
        if(CalibrateCC1020(PA_POWER1))
        {
            lock_status = TRUE;
            sbi(PORTA,LED_PLL);
            // Else (recalibration failed)
        }
        else
        {
            lock_status = FALSE;
            cbi(PORTA,LED_PLL);
        }
    }


    // Switch RX part of CC1020 on				// RX coming out of PD at this stage
    WriteToCC1020Register(CC1020_MAIN,0x01);

    // Configure LOCK pin to continuous lock status. Active low indicates PLL in lock
    //WriteToCC1020Register(CC1020_LOCK,0x20);

    // Configure LOCK pin to indicate carrier sense. Active low when RSSI above threshold
    WriteToCC1020Register(CC1020_LOCK,0x40);

    // Return LOCK status to application
    return (lock_status);
}
Пример #7
0
void SetupCC1020PD(void)
{
  
  // Put CC1020 into power-down
  WriteToCC1020Register(CC1020_MAIN,0x1F);
  
  x = ReadFromCC1020Register(CC1020_MAIN);
  sprintf(arr, "Read: %x\r\n", x);
  //send_UART(arr, strlen(arr));

  // Turn off PA to minimise current draw
  WriteToCC1020Register(CC1020_PA_POWER,0x00);
}
Пример #8
0
void SetupCC1020PD(void)
{
    uint8_t x;
    char bufff[100];

    // Put CC1020 into power-down
    WriteToCC1020Register(CC1020_MAIN,0x1F);

    x = ReadFromCC1020Register(CC1020_MAIN);

    sprintf(bufff,"Wake up complete : %d a\r\n",x);
    usart_transmit(bufff);

    // Turn off PA to minimise current draw
    WriteToCC1020Register(CC1020_PA_POWER,0x00);
}
Пример #9
0
int CalibrateCC1020(char PA_POWER1)
{
    volatile int TimeOutCounter;
    volatile int nCalAttempt;

    // Turn off PA to avoid spurs during calibration in TX mode
    WriteToCC1020Register(CC1020_PA_POWER,0x00);

    // Calibrate, and re-calibrate if necessary:
    for (nCalAttempt = CAL_ATTEMPT_MAX; (nCalAttempt>0); nCalAttempt--)
    {

        // Start calibration
        WriteToCC1020Register(CC1020_CALIBRATE,0xB4);            // verified with cc1020 datasheet

        // Wait for 100 usec. As given errata notes.
        for (int i=0x000B; i > 0; i--);

        // Monitor calibration complete bit in STATUS register
        // CAL_COMPLETE bit set to 1 when calibration is complete
        // Waiting time according to register settings is approx 27ms. Ref_freq=fosc/2 and CAL_WAIT = 11
        // We are waiting for 30ms
        for(TimeOutCounter=30; ((ReadFromCC1020Register(CC1020_STATUS)&0x80)==0x00)&&(TimeOutCounter>0); TimeOutCounter--)
        {
            _delay_ms(1);
        }

        // Monitor lock
        // LOCK_CONTINUOUS bit in STATUS register is set to 1 when PLL is in LOCK
        for(TimeOutCounter=30; ((ReadFromCC1020Register(CC1020_STATUS)&0x10)==0x00)&&(TimeOutCounter>0); TimeOutCounter--)
        {
            _delay_ms(1);
        }

        // Abort further recalibration attempts if successful LOCK
        if((ReadFromCC1020Register(CC1020_STATUS)&0x10) == 0x10)
        {
            break;
        }
    }

    // Restore PA setting
    WriteToCC1020Register(CC1020_PA_POWER, PA_POWER1);

    // Return state of LOCK_CONTINUOUS bit
    return ((ReadFromCC1020Register(CC1020_STATUS)&0x10)==0x10);
}
Пример #10
0
void SetupCC1020Allregisters(void)
{
    char counter, value;

    for(counter = 0x01; counter <= 0x20; counter++)
    {
        value = DefaultConfig433[counter - 1];				// For Transmitter as well as Receiver
        WriteToCC1020Register(counter, value);
    }
}
Пример #11
0
void WakeUpCC1020ToTX(char TXANALOG1)
{

    // Turn on xtal oscillator core
    WriteToCC1020Register(CC1020_MAIN,0xDB);

    // Setup bias current adjustment
    WriteToCC1020Register(CC1020_ANALOG,TXANALOG1);

    // Insert wait routine here, must wait for xtal oscillator to stabilise,
    // typically takes 2-5ms.
    _delay_ms(3);

    // Turn on bias generator
    WriteToCC1020Register(CC1020_MAIN,0xD9);

    // Wait for 150 usec
    _delay_us(150);

    // Turn on frequency synthesiser
    WriteToCC1020Register(CC1020_MAIN,0xD1);
}
Пример #12
0
char SetupCC1020TX(char TXANALOG1, char PA_POWER1)
{
    volatile int TimeOutCounter;
    int lock_status;

    // Turn off PA to avoid frequency splatter
    WriteToCC1020Register(CC1020_PA_POWER,0x00);

    // Setup bias current adjustment
    WriteToCC1020Register(CC1020_ANALOG,TXANALOG1);

    // Switch into TX, switch to freq. reg B
    WriteToCC1020Register(CC1020_MAIN,0xC1);     // TX Coming out of Power down at this stage

    // Monitor lock
    // LOCK_CONTINUOUS bit set to 1 when PLL is in LOCK
    for(TimeOutCounter=30; ((ReadFromCC1020Register(CC1020_STATUS)&0x10)==0x00)&&(TimeOutCounter>0); TimeOutCounter--)
    {
        _delay_ms(1);
    }

    // If PLL in lock
    if((ReadFromCC1020Register(CC1020_STATUS)&0x10)==0x10)
    {
        lock_status = TRUE;
        sbi(PORTA,LED_PLL);
    }
    else	// if PLL is not locked then Recalibrate
    {
        // If recalibration ok
        if(CalibrateCC1020(PA_POWER1))
        {
            lock_status = TRUE;
            sbi(PORTA,LED_PLL);
            // Else (recalibration failed)
        }
        else
        {
            lock_status = FALSE;
            cbi(PORTA,LED_PLL);
        }
    }

    // Restore PA setting
    WriteToCC1020Register(CC1020_PA_POWER,PA_POWER1);

    // Turn OFF DCLK_CS (Carrier Sense Squelch) in TX
    WriteToCC1020Register(CC1020_INTERFACE,ReadFromCC1020Register(CC1020_INTERFACE)&~0x10);

    // Configure LOCK pin to continuous lock status. Active low indicates PLL in lock
    WriteToCC1020Register(CC1020_LOCK,0x20);

    // Return LOCK status to application
    return (lock_status);
}