trilu2000 / NewAskSin

working version of new AskSin framework, which should be more structured then the old one
28 stars 15 forks source link

CC1101 MARCSTATE not correctly detected #20

Closed LineF closed 7 years ago

LineF commented 8 years ago

In CC1101 in function sndData this piece of code always finishes with i=0. A bit of debugging showed me that MARCSTATE returns 0x08 - the cc1101 is in the state of calibrating before sending out data.

Second, if I comment out the second if statement and wait 40ms (uint16_t i runs until 4000), the cc1101 never reaches RX_STATE.

`

for(uint8_t i = 0; i < 200; i++) {                                                  // after sending out all bytes the chip should go automatically in RX mode

    if( readReg(CC1101_MARCSTATE, CC1101_STATUS) == MARCSTATE_RX)
        break;                                                                      //now in RX mode, good
    if( readReg(CC1101_MARCSTATE, CC1101_STATUS) != MARCSTATE_TX) {
        break;                                                                      //neither in RX nor TX, probably some error
    }
    _delay_us(10);
}

` Martin

LineF commented 8 years ago

A bit more information from cc1101 manual and cc1101.cpp: The MCSM1.TXOFF_MODE is by default 0b00 which means that after transmitting data the state machine will go to IDLE. I commented out the second if in the code above and replaced MARCSTATE_RX by MARCSTATE_IDLE. Additionally i should be running to max 2000 (in my example the 14 bytes were sent out in 6,4ms (i=640). Longer payloads therefore should be considered.

Now the code seems to work.

Martin