AnsweredAssumed Answered

STM32F411RET6 - Working with pointers

Question asked by Jibbajibba on Sep 16, 2015
Latest reply on Sep 16, 2015 by Clive One
Hello


Im working on a simple uController software to control a clock. Im working with a Nucleo controllerboard (STM32F411RET6) and uVision Keil V5.
To be able to manipulate acutal variables instead of copies, id like to work with pointers (and as far as i know, char array need to be handled as pointers anyway). 


I placed my questions 1-11 directly at the line where i dont know how to work with those values. thanks for advise.




Software:

// main.h prototypes:


void time_clock_management(int* ss, int* mm, int* hh);    // declare as pointers correct? Question 1
void USART_string_send(char* text);                       // declare as pointer correct? Question 2


// main.c private variables:


char TxOptions[] = "\n\rOptions:\n\r\ts set time\n\r"; //!
uint8_t sec = 0;
uint8_t min = 0;
uint8_t hour = 0;


// main.c functions:


void time_clock_management(int* ss, int* mm, int* hh){    // declare as pointer correct? Question 3
     /* Count */
     *ss++;                                                  // work with variable (acutal value, pointer) instead of adress correct? Question 4
     if(*ss==60){*ss=0; *mm++;}                              // work with variable (acutal value, pointer) instead of adress correct? Warning: expression result unused. Question 5
     if(*mm==60){*mm=0; *hh++;}                              // work with variable (acutal value, pointer) instead of adress correct? Warning: expression result unused. Question 6 
     if(*hh==13){*hh=1;}                                     // work with variable (acutal value, pointer) instead of adress correct? Question 7
}


void USART_string_send(char* text){                       // declare as pointer correct? Question 8
     foo_func_where_param_charArr_is_required(*text);        // place as pointer into a function? Question 9
}


// main.c call functions:


time_clock_management(&sec, &min, &hour);                 // here *pointer, &reference or actual value?? Question 10
USART_string_send(TxOptions);                             // here *pointer, &reference or actual value?? Question 11

Outcomes