SHARE
TWEET

Arduino vs STM32/Cube/HAL

icis4 Apr 24th, 2019 (edited) 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* ----------------- Arduino UNO ----------------------- */
  2. int time_start;
  3. int time_end;
  4.  
  5. void setup() {
  6.   pinMode(LED_BUILTIN, OUTPUT);
  7.   Serial.begin(115200);
  8.   time_start = millis();
  9.   for (int i=0;i < 1e+4; i++)
  10.   {
  11.     digitalWrite(LED_BUILTIN, HIGH);
  12.     digitalWrite(LED_BUILTIN, LOW);
  13.   }
  14.   time_end = millis();
  15.   Serial.print("time_start ");
  16.   Serial.println(time_start);
  17.   Serial.print("time_end ");
  18.   Serial.println(time_end);
  19.   Serial.print("Result ");
  20.   Serial.println(time_end - time_start);
  21. }
  22.  
  23. void loop() {
  24.   delay(10);
  25. }
  26.  
  27. /* Result
  28. time_start 0
  29. time_end 137
  30. Result 137
  31. */
  32. /* ----------------- Arduino UNO ----------------------- */
  33.  
  34.  
  35. /* ----------------- STM32 Nucleo-64-F446RE 16MHz ------ */
  36. //Retargert USART2:
  37. int _write(int fd, char* buff, int len)
  38. {
  39.     if (HAL_UART_Transmit(&huart2, (uint8_t*)buff, len, 100) == HAL_OK)
  40.         return len;
  41.     return 0;
  42. }
  43.  
  44. // main
  45.  
  46.   /* Infinite loop */
  47.   /* USER CODE BEGIN WHILE */
  48.   printf("Hi There!\n");
  49.   uint32_t time_start, time_end;
  50.   time_start = HAL_GetTick();
  51.   for (int i = 0; i < 1e+4; i++) {
  52.       HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_SET);
  53.       HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET);
  54.   }
  55.   time_end = HAL_GetTick();
  56.   printf("Start: %lu\n", time_start);
  57.   printf("End: %lu\n", time_end);
  58.   printf("Total: %lu\n", time_end - time_start);
  59.  
  60.   while (1)
  61.   { ...
  62.  
  63. /*
  64. Hi There!
  65. Start: 1
  66. End: 89
  67. Total: 88
  68. */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top