This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

simple I2C question TC74

I have a TC74 temp sensor

https://www.microchip.com/wwwproducts/en/TC74

and want the temperature 

using code below I always get a greenlight / EVENTS ERROR

thank you in advance for any all help

int main(void)
{
short temperature = 0;

nrf_gpio_cfg_output(42); //output that needs to be off to power MEMs
nrf_gpio_cfg_output(46); //RED
nrf_gpio_cfg_output(47); //GREEN
nrf_gpio_pin_clear(42);
nrf_gpio_pin_set(46);//turns off LED
nrf_gpio_pin_set(47);//turns off LED

NRF_TWIM0->ENABLE=0;//disable nordic as master
NRF_TWIM0->PSEL.SCL=11;//P0.11
NRF_TWIM0->PSEL.SDA=13;//P0.13
NRF_TWIM0->FREQUENCY=0x01980000;//100kHz
NRF_TWIM0->ADDRESS=(0b11001000); // 1001 000--> x100 100 | x 1 fpr read 0 for write
NRF_TWIM0->RXD.PTR = temperature; //store 1 byte temperature in temperature variable
NRF_TWIM0->SHORTS = 0;
NRF_TWI0->INTENSET = 0x061C0202; // set interupts
NRF_TWIM0->ENABLE=6;//enable nordic as master
NRF_TWI0->TASKS_STARTRX = 1;
while (1)
{
if(NRF_TWI0->EVENTS_STOPPED) nrf_gpio_pin_clear(46);
if(NRF_TWI0->EVENTS_ERROR) nrf_gpio_pin_clear(47);//Always comes up with an error
}
}

Parents
  • From what I can see (red light 'pin' 46) i am getting an overrun error.  I dont know how to fix or diagnose this though

    int main(void)
    {
        nrf_delay_ms(500);
        short temperature = 0;
    
        nrf_gpio_cfg_output(42); //output that needs to be off to power MEMs
        nrf_gpio_cfg_output(46); //RED
        nrf_gpio_cfg_output(47); //GREEN
        nrf_gpio_pin_clear(42);
        nrf_gpio_pin_set(46);//turns off LED
        nrf_gpio_pin_set(47);//turns off LED
    
        NRF_TWIM0->ENABLE=0;//disable nordic as master
        NRF_TWIM0->PSEL.SCL=11;//P0.11
        NRF_TWIM0->PSEL.SDA=13;//P0.13
        NRF_TWIM0->FREQUENCY=0x01980000;//100kHz
        NRF_TWIM0->ADDRESS=(0b11001000); // 1001 000--> x100 100 | x 1 fpr read 0 for write
        NRF_TWIM0->RXD.PTR = temperature; //store 1 byte temperature in temperature variable
        NRF_TWIM0->SHORTS = 0;
        NRF_TWI0->INTENSET = 0x061C0202; // set interupts
        NRF_TWIM0->ENABLE=6;//enable nordic as master
        NRF_TWI0->EVENTS_ERROR=0;
        NRF_TWI0->EVENTS_STOPPED=0;
        nrf_delay_ms(250);
        NRF_TWI0->TASKS_STARTRX = 1;
        while (1)
        {
    //    if(NRF_TWI0->EVENTS_STOPPED) nrf_gpio_pin_clear(46);
      //  if(NRF_TWI0->EVENTS_ERROR) nrf_gpio_pin_clear(47);//Always comes up with an error
        if(NRF_TWIM0->ERRORSRC==1) nrf_gpio_pin_clear(46);//Always comes up with an error
        if(NRF_TWIM0->ERRORSRC==2) nrf_gpio_pin_clear(47);
        }
    }
    

Reply
  • From what I can see (red light 'pin' 46) i am getting an overrun error.  I dont know how to fix or diagnose this though

    int main(void)
    {
        nrf_delay_ms(500);
        short temperature = 0;
    
        nrf_gpio_cfg_output(42); //output that needs to be off to power MEMs
        nrf_gpio_cfg_output(46); //RED
        nrf_gpio_cfg_output(47); //GREEN
        nrf_gpio_pin_clear(42);
        nrf_gpio_pin_set(46);//turns off LED
        nrf_gpio_pin_set(47);//turns off LED
    
        NRF_TWIM0->ENABLE=0;//disable nordic as master
        NRF_TWIM0->PSEL.SCL=11;//P0.11
        NRF_TWIM0->PSEL.SDA=13;//P0.13
        NRF_TWIM0->FREQUENCY=0x01980000;//100kHz
        NRF_TWIM0->ADDRESS=(0b11001000); // 1001 000--> x100 100 | x 1 fpr read 0 for write
        NRF_TWIM0->RXD.PTR = temperature; //store 1 byte temperature in temperature variable
        NRF_TWIM0->SHORTS = 0;
        NRF_TWI0->INTENSET = 0x061C0202; // set interupts
        NRF_TWIM0->ENABLE=6;//enable nordic as master
        NRF_TWI0->EVENTS_ERROR=0;
        NRF_TWI0->EVENTS_STOPPED=0;
        nrf_delay_ms(250);
        NRF_TWI0->TASKS_STARTRX = 1;
        while (1)
        {
    //    if(NRF_TWI0->EVENTS_STOPPED) nrf_gpio_pin_clear(46);
      //  if(NRF_TWI0->EVENTS_ERROR) nrf_gpio_pin_clear(47);//Always comes up with an error
        if(NRF_TWIM0->ERRORSRC==1) nrf_gpio_pin_clear(46);//Always comes up with an error
        if(NRF_TWIM0->ERRORSRC==2) nrf_gpio_pin_clear(47);
        }
    }
    

Children
Related