This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2540: about task

Other Parts Discussed in Thread: CC2540

Hi,

   I have written some functions for the EEPROM read/write (eg. AT24C1024). Since there is a write cycle time (Max 30ms written in datasheet), i don't want the MCU run a delay routine for this write cycle time. What will be the best way to implement this? 

Here is my work flow:

P0 interrupt --> received data from other MCU --> read and renew(write) the target address --> (here is a write time cycle) -->update the eeprom data according to the target address.

Regards

Danny

  • Hello Wong,

    That is the max time.  I could be wrong, but I think it is the min time and data hold times that matter.   Since these are i2c devices, I don't think you need an MCU delay, all of that is taken care of in the i2c protocal.  If you place your writing of the new data in an _Event timer, you should not have a problem.

    Thanks,

  • Thanks Greenja

    I have put the write routine into an Event TImer. This timer started after the data is received.

    osal_start_timerEx(taskID,WRITE_EEPROM_EVT,20);

    I toggled a breakpoint in the event timer to see if the program go over the eeprom write routine. It does. However i can't find any signal through the scope. Apparently this routine is skipped. Why would this happen ?

    Regards

    Danny 

  • Hello Danny,

    Lets do some backtracking here.  

    1. Are you using a I2C or SPI EEPROM?

    2. If your are using I2C and the CC2540 you would have to do the i2c in software. Right?

    3. In the IAR debug, you can open the I/O registers and confirm all the port pins you are trying see an output on are actually configured for output.   Manually change the output pin to confirm this.  You will have to do a single step in some cases to see the output change.

    4. You should also be able to single step through the EEPROM write routine and observe the pin changes in the registers.

    Thanks,

  • Hi Greenja

    1. I2C

    2. Yes, those functions are written correctly

    3. I have toggle a breakpoint on I2C_write routine. Program pause once it reached the breakpoint. When i pressed "step into", i still stay in I2C_write ( not enter the I2C_write )

    4. No pin signal changed

    Current situation

    osal_start_timerEx(taskID,WRITE_EEPROM_EVT,100);

    I increased the event period from 20 to 100ms. Data is written into EEPROM successfully

    However, by observing the DSO, the I2C_write process is run after ~75ms but not 100ms. What will be the cause?

    Regards

    Danny

  • Hello Danny,

    So you have successfully written data to the EEPROM?

    The DSO? Is showing less than 100ms for the Event to start ?  Could there be an error in the DSO reading?  What happens if you increase the time to 125ms?

    Which I2C routine are you using?

    Thanks,

  • Hi Greenja

    Yes

    60 --> ~30, 100 --> 75, 125 --> ~ 100, like minus 25ms

    I2C routine is written by myself since i am not sure if CC2540 support I2C

    Regards

    Danny

  • Hello Danny,

    I don't know what could be causing the early triggering of the event, unless you have it called twice somewhere.  The CC2540 does not support I2C.  You shouldn't need to have such a long interval.  This post provides a couple of ways to do I2C on the CC2540 and it is very fast, less than 10ms.

    http://e2e.ti.com/support/low_power_rf/f/158/t/140917.aspx

    Also, you will want to add a timeout so that your code doesn't get stuck trying to read from the I2C.

    Thanks,