Hi, I need your help again :)
My code is:
void main_loop (void) {
tick_loop++;
////////////////////////////////////// BLE entry /////////////////////////////////
blt_sdk_main_loop();
////////////////////////////////////// UI entry /////////////////////////////////
if(tick_loop > (u32)3000){
tick_loop = 0;
uart_dma_send( (unsigned char*)&trans_buff ); //send string "0123"
if(blc_ll_getCurrentState() == BLS_LINK_STATE_CONN){
ble_send_Notify(dataToSend, 8); //send string by BLE - simple Rx/Tx with mobile phone
}
}
}
My question is about "blt_sdk_main_loop();". When BLE state is "Idle" UART doesn't work. It looks like "blt_sdk_main_loop()" blockes program and wait for something. Why? In SDK handbook We can read:
"When Link Layer is in Idle state, no task is processed in Link Layer and Physical Layer; the “blt_sdk_main_loop” function doesn’t act and won’t generate any interrupt, i.e. the whole timing sequence of main_loop is occupied by UI entry"
In my case UART starts work if I connect my device with mobile phone but with wrong result:
Bluetooth connection is OK and send data by BLE is OK.
if i comment "blt_sdk_main_loop()",UART works full correct.
Can someone explain this?
Thanks for all the replies :)
Best regards :)
I have been using the following function and never had any issues:
void at_print(u8 * str){
while(uart_tx_is_busy());
trans_buff.dma_len = 0;
while(*str){
trans_buff.data[trans_buff.dma_len] = *str++;
trans_buff.dma_len += 1;
if(trans_buff.dma_len == UART_DATA_LEN){
uart_dma_send((unsigned char*)&trans_buff);
while(uart_tx_is_busy());
trans_buff.dma_len = 0;
}
}
if(trans_buff.dma_len){
while(uart_tx_is_busy());
uart_dma_send((unsigned char*)&trans_buff);
}
}
Hi,
wes58, your function looks similary, becouse on uart_dma_send(...) function we also check status (busy or not):
volatile unsigned char uart_dma_send(unsigned char* Addr) {
if (reg_uart_status1 & FLD_UART_TX_DONE ) {
reg_dma1_addr = (unsigned short)((unsigned int)Addr); //packet data, start address is sendBuff+1
reg_dma_tx_rdy0 |= FLD_DMA_CHN_UART_TX;
return 1;
}
return 0;
}
I used your function and result is the same.
Summarizing again:
1. First situation:
void main_loop (void) {
tick_loop++;
////////////////////////////////////// BLE entry /////////////////////////////////
blt_sdk_main_loop();
////////////////////////////////////// UI entry /////////////////////////////////
if(tick_loop > (u32)3000){
tick_loop = 0;
uart_dma_send( (unsigned char*)&trans_buff ); //send string "0123"
if(blc_ll_getCurrentState() == BLS_LINK_STATE_CONN){
ble_send_Notify(dataToSend, 8); //send string by BLE - simple Rx/Tx with mobile phone
}
}
}
- before I make a connection to the phone the uart doesn't send data - blt_sdk_main_loop() blocks program
- after i make a connection the uart start send data but wrong data
2. Second situation:
void main_loop (void) {
tick_loop++;
////////////////////////////////////// BLE entry /////////////////////////////////
blt_sdk_main_loop();
////////////////////////////////////// UI entry /////////////////////////////////
if(tick_loop > (u32)3000){
tick_loop = 0;
uart_dma_send( (unsigned char*)&trans_buff ); //send string "0123"
//if(blc_ll_getCurrentState() == BLS_LINK_STATE_CONN){
// ble_send_Notify(dataToSend, 8); //send string by BLE - simple Rx/Tx with mobile phone
//}
}
}
- without send data by BLE
- the same situation like above
3. Third situation:
void main_loop (void) {
tick_loop++;
////////////////////////////////////// BLE entry /////////////////////////////////
//blt_sdk_main_loop(); //without this function
////////////////////////////////////// UI entry /////////////////////////////////
if(tick_loop > (u32)3000){
tick_loop = 0;
uart_dma_send( (unsigned char*)&trans_buff ); //send string "0123"
if(blc_ll_getCurrentState() == BLS_LINK_STATE_CONN){
ble_send_Notify(dataToSend, 8); //send string by BLE - simple Rx/Tx with mobile phone
}
}
}
- uart send data correctly
- BLE dosen't work of course
Do anyone know how to fix it? How to make possible to use BLE and use the "UI entry" correctly?
Best regards
Hi,
Could you try use EVK board to test this problem,or modify the system clock to faster?
Hi,
What crystal do you suggest? I am currently using 24MHz. Should I change to 48MHz?
I have a programmer like in the picture. Have you thought about this tool? I ask, becouse I m new on Telink products.
Maybe the reason of problem is some sleep mode. What do you think?
[Edit]
The sleep mode was a reason. I changed configuration to bls_pm_setSuspendMask (SUSPEND_DISABLE) and now it works :)
Thank you for all the answers.
[/Edit]
Best regards