Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should the first byte of tx buffer be length byte ? #46

Open
uludag2806 opened this issue Sep 17, 2020 · 0 comments
Open

Should the first byte of tx buffer be length byte ? #46

uludag2806 opened this issue Sep 17, 2020 · 0 comments

Comments

@uludag2806
Copy link

Hi;

I do not want to send the lenght of my buffer. I just want to send exactly my buffer but on my code if ı do not send a size of my buffer first and even if I change the inside of my buffer, it continues to send old data. Even PKTCTRL0 (Packet automation control) is "0x05",it is meaning Infinite packet length mode. So ı do not need to send a size of buffer. But my problem is lets say ı am sending a fener[26] buffer and ı delete the send a size of buffer on cc1101_send_packet function and change the sending data lets say ı made packet[26] and reload program again but it still send old(fener[26]) data. but when ı open the sending size function in cc1101_send_packet function

My codes;

void SpiCWriteBurstReg(uint8_t Addr,uint8_t *Buffer,uint8_t Count)
{
uint8_t i=0;
uint8_t temptxburst[Count+2];
HAL_GPIO_WritePin(SPI1_CSn_GPIO_Port, SPI1_CSn_Pin, GPIO_PIN_RESET);
while(HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_6) != GPIO_PIN_RESET);
// temptxburst[0] = SPI_ReadWrite(Addr|WRITE_BURST); // adreside yanlislikla yazdirdigim yer.
temptxburst[0] = Addr|WRITE_BURST;
HAL_SPI_Transmit(&hspi1,&temptxburst[0],1,10);

HAL_SPI_Transmit(&hspi1,Buffer,Count,10); // DATA TOPLU GONDERIM

HAL_GPIO_WritePin(SPI1_CSn_GPIO_Port, SPI1_CSn_Pin, GPIO_PIN_SET);
}

void SPiCWriteReg(uint8_t Addr,uint8_t Value)
{
// SPiCPowerUpReset();
Power_up_reset();
uint8_t Data_Write[2];
Data_Write[0]=Addr;
Data_Write[1]=Value;
HAL_GPIO_WritePin(SPI1_CSn_GPIO_Port, SPI1_CSn_Pin, GPIO_PIN_RESET);
while(HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_6) != GPIO_PIN_RESET);
HAL_SPI_Transmit(&hspi1,Data_Write,2,10);
HAL_GPIO_WritePin(SPI1_CSn_GPIO_Port, SPI1_CSn_Pin, GPIO_PIN_SET);
}

void SpiCStrobe(uint8_t Strobe)
{
HAL_GPIO_WritePin(SPI1_CSn_GPIO_Port, SPI1_CSn_Pin, GPIO_PIN_RESET); //CS enable
while(HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_6) != GPIO_PIN_RESET);
SPI_ReadWrite(Strobe);
HAL_GPIO_WritePin(SPI1_CSn_GPIO_Port, SPI1_CSn_Pin, GPIO_PIN_SET); //CS disable
}

void cc1101_send_packet(uint8_t* txBuffer, uint8_t size)
{

SpiCStrobe(CCxxx0_SIDLE);

SPiCWriteReg(CCxxx0_TXFIFO, size); //I DO NOT WANT TO SEND SIZE . when i close this program is not working correctly.

SpiCWriteBurstReg(CCxxx0_TXFIFO, txBuffer, size);

SpiCStrobe(CCxxx0_STX);
}

uint8_t DataBufferX1[26]= {0x19, 0x44, 0x55, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x65, 0x20, 0x54, 0x75, 0x72, 0x61, 0x6E, 0x20, 0x20, 0x43, 0x43, 0x31, 0x31, 0x30, 0x31, 0x20};
uint8_t fener[26] = {0x66, 0x65, 0x6e, 0x65, 0x72, 0x62, 0x61, 0x68, 0x63, 0x65, 0x20, 0x63, 0x6f, 0x6b, 0x20, 0x79, 0x61, 0x73, 0x61, 0x20, 0x6f, 0x6f, 0x6f, 0x6c, 0x65, 0x79};
uint8_t packet[26] = {0x43, 0x43, 0x31, 0x31, 0x30, 0x31, 0x20, 0x74, 0x61, 0x6d, 0x61, 0x6d, 0x6c, 0x61, 0x6e, 0x64, 0x69, 0x20, 0x59, 0x45, 0x53, 0x53, 0x53, 0x21, 0x21, 0x21};

while (1)
{
HAL_Delay(500);
SpiCStrobe(CCxxx0_SFTX);

cc1101_send_packet(fener,26 );

while(HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_2) == GPIO_PIN_SET);// while(HAL_GPIO_ReadPin(GDO0_GPIO_Port, GDO0_Pin));
while(HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_2) != GPIO_PIN_SET);// while(!HAL_GPIO_ReadPin(GDO0_GPIO_Port, GDO0_Pin));

}

and ı make also ;

  1.  I made the changes 
    

0x04, // PKTCTRL0 Packet automation control.

0x1A // PKTLEN Packet length (in decimal 26)

  1.  I delete the sending size of buffer 
    

void cc1101_send_packet(uint8_t* txBuffer, uint8_t size)
{

SpiCStrobe(CCxxx0_SIDLE);

// SPiCWriteReg(CCxxx0_TXFIFO, size); ***************************
SpiCWriteBurstReg(CCxxx0_TXFIFO, txBuffer, size);

SpiCStrobe(CCxxx0_STX);
}

  1.  Result;
    
  1. sending data:uint8_t packet[26] = {0x43, 0x43, 0x31, 0x31, 0x30, 0x31, 0x20, 0x74, 0x61, 0x6d, 0x61, 0x6d, 0x6c, 0x61, 0x6e, 0x64, 0x69, 0x20, 0x59, 0x45, 0x53, 0x53, 0x53, 0x21, 0x21, 0x21};

1.receive data: 1A 43 43 31 31 30 31 20 74 61 6D 61 6D 6C 61 6E 64 69 20 59 45 53 53 53 21 21

NOTE: as you see first byte 1A means in decimal 26 so it still send the old data because i did not send the size. i have no idea about how this happened?

2.sending data: fener[26] = {0x66, 0x65, 0x6e, 0x65, 0x72, 0x62, 0x61, 0x68, 0x63, 0x65, 0x20, 0x63, 0x6f, 0x6b, 0x20, 0x79, 0x61, 0x73, 0x61, 0x20, 0x6f, 0x6f, 0x6f, 0x6c, 0x65, 0x79};

2.receive data: 66 43 43 31 31 30 31 20 74 61 6D 61 6D 6C 61 6E 64 69 20 59 45 53 53 53 21 21

NOTE:As you see just change the first byte. first byte is true but the rest of the buffer are old information.

  1. But when i use SPiCWriteReg(CCxxx0_TXFIFO, size); (mean send the size of buffer) every message goes true. But ı dont want to send length of buffer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant