How to set SDA= p0.25;and SCL=P0.26 default pin configration.
How to set SDA= p0.25;and SCL=P0.26 default pin configration.
You don't use UICR for that.
You use either sdk_config.h or the custom board header file for your board (when using NRF SDK).
Thank you for reply.
how can i go through sdk_config.h file.please explain me
If you are using the TWI driver in the SDK (nrf_drv_twi), the GPIO pin numbers are set in the config struct passed to nrf_drv_twi_init(). For instance, in the twi_sensor example, the ARDUINO_SCL/SDA pins are used:
void twi_init (void) { ret_code_t err_code; const nrf_drv_twi_config_t twi_lm75b_config = { .scl = ARDUINO_SCL_PIN, .sda = ARDUINO_SDA_PIN, .frequency = NRF_DRV_TWI_FREQ_100K, .interrupt_priority = APP_IRQ_PRIORITY_HIGH, .clear_bus_init = false }; err_code = nrf_drv_twi_init(&m_twi, &twi_lm75b_config, twi_handler, NULL); APP_ERROR_CHECK(err_code); nrf_drv_twi_enable(&m_twi); }
These pins are defined in the pca10040.h board header file:
#define ARDUINO_SCL_PIN 27 // SCL signal pin #define ARDUINO_SDA_PIN 26 // SDA signal pin
You can define your own pins in the application:
#define TWI_SCL_PIN 26 // SCL signal pin #define TWI_SDA_PIN 25 // SDA signal pin
And then set these in the config struct.
thank you, but i want default pin configuration. after reset and erase their is no changes to defined pin.
i think above are user defined pin configration .
I'm not sure what you mean by "default pin configuration". There is no default pin config for the peripheral. Any GPIO can be configured to be used with any serial peripheral. You need to define the pin usage in the application. The pin configuration can be changed in run-time. If you erase the chip, it will not have any TWI peripheral configured so the pin config will be irrelevant. The pin config will always be set on boot by your application.
How to update pin configuration for sda and scl to board permanent via bootloader.
You simply cannot do that - the application has full control over which gpio pin has what digital function assigned to. Simply by putting the correct magic number in the peripherial register (PSEL.XXX).
You simply cannot do that - the application has full control over which gpio pin has what digital function assigned to. Simply by putting the correct magic number in the peripherial register (PSEL.XXX).
can you explain in depth please .
Can you explain in depth why you think you needed that feature, and what you did not understand in the PS, TWI and TWIM chapters?
for the appliaction purpose design our own IC of nrf52. so i need the default pin configuration for that. can you explain me nrf_sdk I2c example. I am new for nrf so i didn't understand their example.
#define TWI0_CONFIG_FREQUENCY NRF_TWI_FREQ_100K
#define TWI0_CONFIG_SCL 0x1b
#define TWI0_CONFIG_SDA 0x1a
Is this PSEL_xx register configuration??
0x1b and 0x1a are bit selection in PSEL.SCA and PSEL.SDA ???
if these are correct, then tell me how they get write this exact vslues on the register?
The PS (V1.4, chapter 49.8.6) leaves no ambiguity here:
"PSELSCL [0..31] Pin number configuration for TWI SCL signal".
Any experienced programmer can calculate the decimal pin number from those simple hex values - and everybody else just uses windows calculator in programmer mode.
SCL is P0.26, SDA is P0.27 as shown here.
Dunno why the values are encoded in hex in your case. Decimal values work fine here, and would match the P0.xx values from the PS.