Ola a todos, acabei de fazer um curso de revisao em C voltado para embedded. Foi discutido muito sobre o uso do volatile para nao deixar o compilador otimizar o codigo. Observei que mesmo que ja tinha uma certa experiencia....coisa que nao e o meu caso.......ficaram meio confusos sobre o uso de static, const e volatile.
Vejo muito exemplos que utilizacao nesse formato uint8_t, unit8_t ou somente unsigned char var, unsigned int var. Estou lendo esse livro que fala sobre a necessidade de padronizar o C para uso no embedded.
Minha duvida e a sequinte.....pq static, const e volatile sendo tao importante nao sao implementadas como deveriam? Sinceramente fico confuso quando estou analizando um codigo.
Alguem com experiencia poderia explicar quando e pq usa-los com exemplos. Obrigados a todos
Livro - Embedded C Coding Standard.
The static keyword shall be used to declare all functions and variables that do not need to be visible outside of the module in which they are declared.
The const keyword shall be used whenever appropriate. Examples include:
1- To declare variable that should not be changed after initialization,
2- To declare call-by- reference function parameters that should not be modified (ex. char const *param),
3- To define fields in structs and unions that should not be modified (ex. In a struct overlay for memory-mapped I/O peripheral registers), and
4- As a strongly typed alternative to #define for numerical constants.
The volatile keyword shall be used whenever appropriate. Examples include:
1-To declare a global variable accessible (by current use or scope) by any interrupt service routine,
2- To declare a global variable accessible (by current use or scope) by two or more taskes,
3- To declare a pointer to a memory- I/O peripheral register set (ex. timer_t volatile *const p_timer),
4-To declare a delay loop counter.
--
Você está recebendo esta mensagem porque se inscreveu no grupo "sis_embarcados" dos Grupos do Google.
Para cancelar a inscrição neste grupo e parar de receber seus e-mails, envie um e-mail para sis_embarcado...@googlegroups.com.
Para postar neste grupo, envie um e-mail para sis_emb...@googlegroups.com.
Visite este grupo em http://groups.google.com/group/sis_embarcados.
Para obter mais opções, acesse https://groups.google.com/groups/opt_out.
--
Você recebeu esta mensagem porque está inscrito em um tópico do grupo "sis_embarcados" dos Grupos do Google.
Para cancelar a inscrição neste tópico, acesse https://groups.google.com/d/topic/sis_embarcados/jjmx3wdqeVg/unsubscribe.
Para cancelar a inscrição neste grupo e todos os seus tópicos, envie um e-mail para sis_embarcado...@googlegroups.com.
Livro - Embedded C Coding Standard.
The static keyword shall be used to declare all functions and variables that do not need to be visible outside of the module in which they are declared.
The const keyword shall be used whenever appropriate. Examples include:
1- To declare variable that should not be changed after initialization,
2- To declare call-by- reference function parameters that should not be modified (ex. char const *param),
3- To define fields in structs and unions that should not be modified (ex. In a struct overlay for memory-mapped I/O peripheral registers), and
4- As a strongly typed alternative to #define for numerical constants.
The volatile keyword shall be used whenever appropriate. Examples include:
1-To declare a global variable accessible (by current use or scope) by any interrupt service routine,
2- To declare a global variable accessible (by current use or scope) by two or more taskes,
3- To declare a pointer to a memory- I/O peripheral register set (ex. timer_t volatile *const p_timer),
4-To declare a delay loop counter.
Você vai aplicar nestas condições.
Hehehehehe....
Você nunca ouviu seu professor falar que na prática a teoria é outra?
Abraços.
Alessandro Ferreira da Cunha
TECHtraininG - ENGENHARIA E TREINAMENTOS
aless...@techtraining.eng.br
SKYPE --> alessandroferreiradacunha
twitter --> @prof_afcunha
(11) 995–363-828
www.techtraining.eng.br
Enviado por uma Beagle Bone Black
Alguém saberia informar se o kit abaixo é atrativo na promoção de thanksgiving???? In case anyone is interested, we have another Thanksgiving promo this year This week only - grab a Mercury 50K FPGA board for just $39.99! Use coupon code "FARADAY". While supplies last! Limit one per customer. http://micro-nova.com/mercury mark2112 wrote
--
--
Você recebeu esta mensagem porque está inscrito em um tópico do grupo "sis_embarcados" dos Grupos do Google.
Para cancelar a inscrição neste tópico, acesse https://groups.google.com/d/topic/sis_embarcados/jjmx3wdqeVg/unsubscribe.
Para cancelar a inscrição neste grupo e todos os seus tópicos, envie um e-mail para sis_embarcado...@googlegroups.com.