- #include <mega8515.h>
- //8MHz CB1 final 29 April without pulse strecher
- #include<stdio.h>
- #include<delay.h>
- // Declare your global variables here
- char a;
- bit dlag,ulag;
- char str[16];
- int dly=0;
- void blink();
- void blink2();
- void main(void)
- {
- DDRB=0xFF;
- DDRC=0x80;
- PORTC=0x00;
- ACSR=0x80;
- while (1)
- {
- a=PINC;
- a^=0x70;
- if(a&0x20) {PORTB=0x02; blink2();
- }
- else if(a&0x40) {PORTB=0x01; blink2();
- }
- else if(a&0x10) {PORTB=0x00; blink2();
- }
- else
- {
- if(a)
- {
- switch(a)
- {
- case 1: //Move Down
- PORTB=0x06;;
- delay_ms(200);
- dly=0;
- break;
- case 3: //Move Down Sort Steps
- PORTB=0x06;
- delay_ms(100);
- dly=0;
- break;
- ////////////////////////////////////
- case 2: //Move Down Long Steps
- if(ulag)
- {
- delay_ms(250); ulag=0;
- }
- else
- { PORTB=0x06;
- delay_ms(35);
- dly=15; dlag=1;
- }
- break;
- /////////////////////////////////
- case 6: //Don't move
- PORTB=0x08; delay_ms(200);
- dly=10; ulag=0; dlag=0;
- break;
- ///////////////////////////////////////////
- case 4: //Move Up in Steps
- if(dlag)
- { delay_ms(250); dlag=0;
- }
- else
- {
- PORTB=0x11; delay_ms(35);
- dly=15; ulag=1;
- }
- break;
- ////////////////////////////////////////////
- case 12: //Move Up in Short steps
- PORTB=0x11; delay_ms(90);
- dly=0;
- break;
- case 8: //Move Up in Long Steps
- PORTB=0x11; delay_ms(190);
- dly=0;
- //Long or Short steps is controlled by the time delay
- }
- }
- else
- {
- //Make all OFF
- PORTB=0;
- delay_ms(dly);
- }
- }
- };
- }
- void blink()
- {
- a&=0x0F;
- switch(a)
- {
- case 1: //Move Down
- PORTB=0x04;;
- delay_ms(200);
- dly=0;
- break;
- case 3: //Move Down Sort Steps
- PORTB=0x04;
- delay_ms(100);
- dly=0;
- break;
- //////////////////////////////////////////
- case 2: //Move Down Long Steps
- PORTB=0x04;
- delay_ms(50);
- dly=15;
- break;
- ///////////////////////////////////
- case 6: //Don't move
- PORTB=0x08; delay_ms(80);
- dly=10;
- break;
- ///////////////////////////////////
- case 4: //Move Up in Steps
- PORTB=0x10; delay_ms(50);
- break;
- //////////////////////////////////
- case 12: //Move Up in Short steps
- PORTB=0x10; delay_ms(90);
- dly=0;
- break;
- case 8: //Move Up in Long Steps
- PORTB=0x10; delay_ms(190);
- dly=0;
- //Long or Short steps is controlled by the time delay
- }
- }
- void blink2()
- {
- a&=0x0F;
- switch(a)
- {
- case 1: //Move Down
- PORTB.2=1;
- delay_ms(200);
- dly=0;
- break;
- case 3: //Move Down Sort Steps
- PORTB.2=1;
- delay_ms(100);
- dly=0;
- break;
- /////////////////////////////////
- case 2: //Move Down Long Steps
- PORTB.2=1;
- delay_ms(50);
- dly=15;
- break;
- ////////////////////////////////
- case 6: //Don't move
- PORTB.3=1; delay_ms(80);
- dly=10;
- break;
- /////////////////////////////////////
- case 4: //Move Up in Steps
- PORTB.4=1; delay_ms(50);
- break;
- ////////////////////////////////////
- case 12: //Move Up in Short steps
- PORTB.4=1; delay_ms(90);
- dly=0;
- break;
- case 8: //Move Up in Long Steps
- PORTB.4=1; delay_ms(190);
- dly=0;
- //Long or Short steps is controlled by the time delay
- }
- }
1. What is a Stub function? Ans : A function without any definition which presents no error when called. 2. Why there are two ld scripts generated by STM32Cube IDE? Ans: The CubeIDE always presents two different LDscripts on for generating the executable for Debugging which goes to RAM another for normal code upload that goes to flash memory. 3. What is Supervisory Mode/ privileged mode ? Ans : When you are using a Kernel then there are two modes user mode and privileged mode. In User mode the applications cant have system calls. 4. What is "make -j6" ? Ans : Make has an argument for number of jobs, so when you add -j6 it will create 6 different compiler instances, so that the systems could use multicore to the fullest. Linux people generally do add "-j $(nproc)" where nproc is a command line which returns number of processors attached. 5. What is weak attribute ? Ans : Weak attribute used to denote weak symbols which helps linkers to choose one function out of mul...
Comments
Post a Comment