Using the nRF51422 with the TWI hardware version. Just playing around to verify signals with the following code which just configures the TWI1 and then repeats continuously with a master transmit of one data byte=0x57.
I get a 7 clock transitions on SCL along with the 0x57 on the SDA, but it never transmits the addresss. It seems once data is placed in the TXD, it automatically sends it out. I have tried reversing the start and TXD register steps as in the canned code and add a stop task but it is always the same, no address. What am I doing wrong?
thanks
/******************************************************************************************************************/
twi_master_config();
nrf_delay_ms(100);
NRF_TWI1->ADDRESS=0x78;
while(1) //endless single byte transmission
{
NRF_TWI1->TASKS_STARTTX=1;
NRF_TWI1->TXD=0X57;
nrf_delay_ms(10);
}
void twi_master_config(void)
{
NRF_TWI1->ENABLE=0; //disable TWI
NRF_GPIO->PIN_CNF[2] =
(GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos)
| (GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos)
| (GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos)
| (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos)
| (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos);
NRF_GPIO->PIN_CNF[0] =
(GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos)
| (GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos)
| (GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos)
| (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos)
| (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos);
NRF_TWI1->EVENTS_RXDREADY = 0;
NRF_TWI1->EVENTS_TXDSENT = 0;
NRF_TWI1->PSELSCL = 0x00000002; //SCL
NRF_TWI1->PSELSDA = 0x00000000; //SDA
NRF_TWI1->FREQUENCY = 0x01980000; //100k
NRF_PPI->CH[0].EEP = (uint32_t)&NRF_TWI1->EVENTS_BB;
NRF_PPI->CH[0].TEP = (uint32_t)&NRF_TWI1->TASKS_SUSPEND;
NRF_PPI->CHENCLR = PPI_CHENCLR_CH0_Msk;
NRF_TWI1->ENABLE = 1;
}
/******************************************************************************************************************/