Microcontrollers, C language, debugging, EEPROM, programming functions, LED control, buzzer, interrupt routine, conditional structures
A practical work report on using C language for microcontrollers, covering debugging, EEPROM access, and programming functions.
[...] language. 1.2.4 Application Here the code complet each function will be commented more far except if the function in question a has already been analyzed or if this is not relevant. 11 12 e f i n e D i d e n t i f i a n t pour l a l e d D2 13 e f i n e D i d e n t i f i a n t pour l a l e d D3 14 e f i n e D i d e n t i f i a n t pour l a l e d D4 15 e f i n e D i d e n t i f i a n t pour l a l e d D5 16 e f i n e ON 1 pour allumer 17 e f i n e OFF 0 pour é te i n d r e 18 19 20 CONFIG(HS & WDTDIS & BOREN & LVPDIS ) ; 21 22 char debug @0x70 ; é v i t e r c o n f l i t s with ICD3 23 24 void i n i t_p o r t ( void ) 25 { 26 TRISB = 0 ; l e s 8 b I t s de TRISB à 0 so PORTB and n t i e r en sortie 27 PORTB = 0 ; The LEDS are to and the s é the e i n t e s 28 } 29 te m p o r s i a t i o n s f i x e s 30 Pour 1ms 31 void tempo1ms ( void ) 32 { 33 i n t i ; 34 f o r ( i = 0 ; i i 35 36 } 37 Pour 1 s 38 void tempo1s ( void ) 39 { 40 i n t i ; 41 f o r ( i = 0 ; i [...]
[...] When i l s ' allume , 72 on vé r i f i e i l e bouton p o u s s o r e s t p r e s s é , i c ' e s t l e cas l a LES 73 s ' é t e i n t s inon e l l e p o u r s u i t l e meme p r i n c i p e 5 f o i s en tout . 74 The all lasts 5 s . [...]
[...] 1 Ve r i f i e what l port en q u e s t i o n vaut 0 2 void i n i t_p o r t ( void ) 3 { 4 //TRISB = TRISB b i t ( 0 ) ; Line à change 5 TRISB=TRISB&(~ b i t ( 0 ) ) ; mise à 0 du b i t 0 part l a technique des masques 6 TRISB0 = 0 ; mise à 0 du b i t 0 part l a technique des noms symboliques 7 } 1.2.2 Choice of the tool of debugging We have written in C the function tempo1s which performs a fixed timing of 1 second from a function tempo1ms of a fixed duration of 1 ms and use it to write the function afterwards tempo1s. In checking using the StopWatch feature, we were able to see that the duration of the tempori- sation dure well 1ms. [...]
[...] La function init_port va allow to initialise the ports of B in sortie and of the to define à 0 as follows : 1 void i n i t_p o r t ( void ) 2 { 3 TRISB = 0 ; l e s 8 b I t s de TRISB à 0 so PORTB and n t i e r en 4 s o r t i e PORTB = 0 ; Les LEDS are to u te s é t e i n t e s 5 } The function tempo_p_ms est useful for generating a timing according to the needs of the pro- grammeur. Son principle is the even what in language assembler but this this time with a loop for easier to implement. The function led, here is the most important, must fill the following specification sheet : the following call in the main : led (D3,off ) will turn off the led D3. [...]
[...] 19 buzzer_on 20 21 buzzer_off ( ) ; 22 compteur = 0 ; 23 24 25 1.5 Access to the EEPROM of data For this part us let's go pas explain each function like we we have fait previously ment but juste commenter the programme directly and explain the inspiration. - write_data_eeprom : this function a been detailed and written in assembler aux pages 66 and 67 of the file Summary of the course during TP PIC that we translated in C ; - read_data_eeprom : this function a been detailed and written in assembler to the page 63 from the file Summary of the course during PIC TP that we translated in C ; - write_and_verify_data_eeprom don't look at the specification sheet is on page 68 of the file Summary of the course during TP PIC. [...]
APA Style reference
For your bibliographyOnline reading
with our online readerContent validated
by our reading committee