how I can to activate the password on nRF51822 for connect to BLE?
The BLE Pairing Algorithms are described in Vol 3, Part H, Section 2.3.5 in the Bluetooth Core specification, v4.2.
In short, you need to set that MITM protection is required in the GAP security parameters (see the ble_gap_sec_params_t struct). Then the IO capabilities of the devices will be used in the pairing process. Table 2.9 displays what IO combinations that will trigger a passkey entry. I'm assuming you are using a nRF51 DK, this doesn't have a keyboard or display, so NoInputNoOutput should be used as IO capability. This does not however trigger a passkey entry.
You could however set the IO capability to DisplayOnly and set the passkey to a static value. Then you don't need to actually display the key to know what it is. Please see this MSC.
I have added this static passkey functionality in the ble_app_uart example in SDK 8.1.0, please examine this.
Edit 21.05.2015: Fixed a mistake in the project.
What are you testing this with? Are you actually pairing? Please use MCP or nRF MCP. If you want to use nRF UART you need to change the permission of the attributes permissions with BLE_GAP_CONN_SEC_MODE_SET_ENC_WITH_MITM(), like here.
What are you testing this with? Are you actually pairing? Please use MCP or nRF MCP. If you want to use nRF UART you need to change the permission of the attributes permissions with BLE_GAP_CONN_SEC_MODE_SET_ENC_WITH_MITM(), like here.