![]() ![]() It is also called “IIC” or ‘I squared C”. I2C is an abbreviation for “Inter-Integrated Circuit”. Times have changed, Phillips is now NXP and I2C has become a communication standard that is supported by virtually every major semiconductor manufacturer. It was originally developed by Phillips in 1982 to allow integrated circuits within television receivers to communicate with one another. I2C is a serial protocol used on a low-speed 2-wire interface. In future articles we will see how we can build our own I2C devices, how to interface a Raspberry Pi and an Arduino using I2C and how to do some advanced I2C configurations, including using multiple masters on one I2C bus. This will be the first of four articles on I2C. We’ll also see how it can be used to exchange information between two Arduinos and how it can be used to allows one Arduino to control another one. Today we will correct that and learn more about I2C. Serial.Although we have used many I2C sensors and displays in previous articles we have not actually looked into how I2C works and how it can be used to communicate between microcontrollers. Serial.println("Enter the main loop : Restart watchdog") Serial.print("RSTTYP = 0b") Serial.println(status, BIN) // Should be 0b010 after first watchdog reset Uint32_t status = (RSTC->RSTC_SR & RSTC_SR_RSTTYP_Msk) > 8 // Get status from the last Reset WDV holds the periode in 256 th of seconds */ Watchdog frequency is therefore 32768 / 128 = 256 Hz | WDT_MR_WDV(256 * 2) // Watchdog triggers a reset after 2 seconds if underflow This function has to be overriden, otherwise watchdog won't work !! */ This function, then the default action is to disable watchdog. Void watchdogSetup (void) _attribute_ ((weak, alias("_watchdogDefaultSetup"))) In the 1.6.7 version this is the code I use to enable watchdog, and I guess it works for later versions : #define WDT_KEY (0xA5) On the other hand, once you have modified the file variant.cpp, you have to insert a call to WDT_Disable() at the beginning of your sketches than don't use the watchdog: void setup() The following value set a periode of 4,5 seconds (256 x 4,5 = 1152) It must be greater than 3 et less or equal to 4096 Variable wdp_ms hold the periode in 256 th of seconds of watchdog In the following example, the variable waitTime would never reach a value higher than 5: int waitTime = 0 This can be done only once after reset and the maximum value 4096 is equivalent to 4096 / 256 = 16 seconds. This function modify the Watchdog Timer Mode Register. Optionally, you can reduce the period of the watchdog with a call to WDT_Enable(). So, when variable waitTime reach the value of 16, watchdog' counter reach 0 before the delay() function finish and a reset occurs. Serial.print( "Following function last " ) īy default, watchdog period is set to its maximum value, 16 seconds. ![]() Second, insert at the beginning of the loop() function a call to function WDT_Restart() in order to restart the watchdog' timer each time the loop is executed. First, it is necessary to comment line 353 of file variant.cpp in subdirectory * arduino-1.5.2\hardware\arduino\sam\variants\arduino_due_x* // Disable watchdog ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |