Hello,
I have here nrf52832 installed in a wristwatch called PineTime.
I program nrf52832 directly (only gcc none eabi), completely without SDK and without SoftDevice. This works very well so far.
Now for weeks I try in vain to activate Bluetooth and send ADV_IND. This does not succeed. To receive my tests I have nrf52840-dongle with WireShark. Somehow it doesn't matter what I do. I can not receive anything from my nrf52832. I receive all kinds of other devices around me. But not my nrf52832.
Can someone help me possibly? Or is there somewhere possibly a simple example how sending adv_ind works successfully. Or can you point me to errors in my code?
Thanks in advance.
#define BLUE_TASK_TX_ENABLE *(volatile unsigned int *) 0x40001000
#define BLUE_TASK_RX_ENABLE *(volatile unsigned int *) 0x40001004
#define BLUE_TASK_START *(volatile unsigned int *) 0x40001008
#define BLUE_TASK_STOP *(volatile unsigned int *) 0x4000100C
#define BLUE_TASK_DISABLE *(volatile unsigned int *) 0x40001010
#define BLUE_EVENT_READY *(volatile unsigned int *) 0x40001100
#define BLUE_EVENT_ADDRESS *(volatile unsigned int *) 0x40001104
#define BLUE_EVENT_PAYLOAD *(volatile unsigned int *) 0x40001108
#define BLUE_EVENT_END *(volatile unsigned int *) 0x4000110C
#define BLUE_EVENT_DISABLED *(volatile unsigned int *) 0x40001110
#define BLUE_SHORTS *(volatile unsigned int *) 0x40001200
#define BLUE_INTERRUPT_SET *(volatile unsigned int *) 0x40001304
#define BLUE_INTERRUPT_CLEAR *(volatile unsigned int *) 0x40001308
#define BLUE_CRC_STATUS *(volatile unsigned int *) 0x40001400
#define BLUE_PACKET_PTR *(volatile unsigned int *) 0x40001504
#define BLUE_FREQUENCY *(volatile unsigned int *) 0x40001508
#define BLUE_TX_POWER *(volatile unsigned int *) 0x4000150C
#define BLUE_MODE *(volatile unsigned int *) 0x40001510
#define BLUE_PACKET_CONFIG_0 *(volatile unsigned int *) 0x40001514
#define BLUE_PACKET_CONFIG_1 *(volatile unsigned int *) 0x40001518
#define BLUE_BASE_ADDRESS_0 *(volatile unsigned int *) 0x4000151C
#define BLUE_BASE_ADDRESS_1 *(volatile unsigned int *) 0x40001520
#define BLUE_PREFIX_ADDRESS_0 *(volatile unsigned int *) 0x40001524
#define BLUE_PREFIX_ADDRESS_1 *(volatile unsigned int *) 0x40001528
#define BLUE_TX_ADDRESS *(volatile unsigned int *) 0x4000152C
#define BLUE_RX_ADDRESSES *(volatile unsigned int *) 0x40001530
#define BLUE_CRC_CONFIG *(volatile unsigned int *) 0x40001534
#define BLUE_CRC_POLY *(volatile unsigned int *) 0x40001538
#define BLUE_CRC_INIT *(volatile unsigned int *) 0x4000153C
#define BLUE_STATE *(volatile unsigned int *) 0x40001550
#define BLUE_DATA_WHITENING_INIT_VALUE *(volatile unsigned int *) 0x40001554
#define BLUE_RADIO_MODE_CONFIG *(volatile unsigned int *) 0x40001650
#define BLUE_POWER *(volatile unsigned int *) 0x40001FFC
#define BLUETOOTH_STATE_DISABLED 0
#define BLUETOOTH_STATE_RX_RU 1
#define BLUETOOTH_STATE_RX_IDLE 2
#define BLUETOOTH_STATE_RX 3
#define BLUETOOTH_STATE_RX_DISABLE 4
#define BLUETOOTH_STATE_TX_RU 9
#define BLUETOOTH_STATE_TX_IDLE 10
#define BLUETOOTH_STATE_TX 11
#define BLUETOOTH_STATE_TX_DISABLE 12
static unsigned char blue_ram_tx_buffer[256];
// Bluetooth
// Data
blue_ram_tx_buffer [ 0] = 0x00; // BLE Header (PDU_TYPE: SCAN_REQ, TXadd, RXadd)
blue_ram_tx_buffer [ 1] = 0x0C; // Length of payload: 12
blue_ram_tx_buffer [ 2] = 0xDE; // InitAddr LSByte first
blue_ram_tx_buffer [ 3] = 0xDE;
blue_ram_tx_buffer [ 4] = 0xDE;
blue_ram_tx_buffer [ 5] = 0xDE;
blue_ram_tx_buffer [ 6] = 0xDE;
blue_ram_tx_buffer [ 7] = 0xDE;
blue_ram_tx_buffer [ 8] = 0xAA; // AdvAddr LSByte first
blue_ram_tx_buffer [ 9] = 0xAA;
blue_ram_tx_buffer [10] = 0xAA;
blue_ram_tx_buffer [11] = 0xAA;
blue_ram_tx_buffer [12] = 0xAA;
blue_ram_tx_buffer [13] = 0xAA;
// Bluetooth Reset
BLUE_POWER = 0; // Bluetooth PowerOFF
for (unsigned int i=0xFF;i>0;i--) {;} // Small break (how long, not defined anywhere)
BLUE_POWER = 1; // Bluetooth PowerON
// Bluetooth Set signal strength
BLUE_TX_POWER = 0; // 0 dBm
// Frequency for transmission
BLUE_FREQUENCY = 2; // 2402 MHz - Corresponds to channel 37
// Datawhithening Init
BLUE_DATA_WHITENING_INIT_VALUE = 0xFF; // Is that correct?
// Advertising Address 0x8E89BED6
BLUE_PREFIX_ADDRESS_0 = 0x8E;
BLUE_BASE_ADDRESS_0 = 0x89BED600;
// Select Address
BLUE_TX_ADDRESS = 0x00; // (prefix0 + base0) = 0x8E89BED6
BLUE_RX_ADDRESSES = 0x01;
// Radio Mode
BLUE_MODE = 3; // 3 - BLE 1Mbit
// Radio config
BLUE_RADIO_MODE_CONFIG = 1 | (2 << 8); // Fast Ramp-Up + Transmit-Center-Frequency
// Konfiguration
BLUE_PACKET_CONFIG_0 = 0; // 0 - LFLEN (bits); 0 - S0 (bytes); 0 - S1 (bits);
BLUE_PACKET_CONFIG_1 = 15 | (3 << 16) | (1 << 25); // 15 - Maxlen; 3 - Balen; 1 - Whiteening
// CRC Config
BLUE_CRC_CONFIG = 3 | (1 << 8); // 3 - CRC-Bytes; 1 - Exclude address
BLUE_CRC_INIT = 0x00555555; // Initial value CRC (24 Bit)
BLUE_CRC_POLY = 0x0000065B; // Would be standart for BLE (24 Bit)
// Clear events
BLUE_EVENT_READY = 0;
BLUE_EVENT_END = 0;
BLUE_EVENT_ADDRESS = 0;
BLUE_EVENT_PAYLOAD = 0;
BLUE_EVENT_DISABLED = 0;
// PTR to Data
BLUE_PACKET_PTR = (unsigned int) &blue_ram_tx_buffer;
// Radio Ramp Up
BLUE_TASK_RX_ENABLE = 0;
BLUE_TASK_TX_ENABLE = 1;
// Wait until radio is ready
while (BLUE_EVENT_READY == 0) {;}
while (BLUE_STATE != BLUETOOTH_STATE_TX_IDLE) {;}
// Start radio TX
BLUE_TASK_START = 1;