Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // problema 3, laborator 1
- unsigned int i;
- int var;
- //variabila folosit pentru a trece de la un led la altul
- // ledul 6
- int led1=6;
- // ledul 11 shiftat cu 2 la dreapta
- int led2=13;
- //direction register
- *pPORTFIO_DIR=0x0FFC;
- *pPORTFIO_DIR&= ~((1<<3)|(1<<4));
- //input enable register
- *pPORTFIO_INEN=0x00018;
- while(1) {
- //folosim butonul 4.
- //reset
- if((*pPORTFIO&(1<<4))!=0)) {
- *pPORTFIO=0x0000;
- for(i=0;i<1000;i++);
- if((*pPORTFIO&(1<<4))!=0)){
- //cat timp butonul este apasat
- while((*pPORTFIO&(1<<4))!=0));
- //aprindem ledul urmator
- *pPORTFIO|= (1<<var);
- //in acelasi timp se stinge cel anterior
- *pPORTFIO&=~(1<<var-1);
- //se trece la urmatorul
- var++;
- //
- if(led1==13) {
- *pPORTFIO&=~(1<<12);
- led1=6;
- *pPORTFIO|=(1<<6);}}}}
- // laborator 2
- #include <sys/platform.h>
- #include <adi_initialize.h>
- #include <test.h>
- #include <cdefbf537.h>
- #include <sys/exception.h>
- volatile unsigned int i;
- EX_INTERRUPT_HANDLER(ISR_TIMER7){
- //for(i=0;i<9999;i++)
- i++;
- if(i%2==0)
- *pPORTFIO &= ~ (1<<9);
- else
- *pPORTFIO |= (1<<9);
- *pTIMER_STATUS=0x00000000;
- }
- void initInterrupts(void) {
- *pSIC_IAR3 = 0xFFFFF5FF;
- *pSIC_MASK = 0x04000000;
- register_handler(ik_ivg12, ISR_Timer7);
- }
- int main(int argc, char *argv[]){
- int i;
- //alegem led-urile ca iesiri
- *pPORTFIO_DIR=0xFFCF;
- //configurare timer
- *pTIMER7_CONFIG = 0x001D;
- //perioada timer, perioada de numarare = 0.5
- *pTIMER_PERIOD = 0x17D7840;
- *pTIMER_ENABLE = 0x0080;
- //oprim led-urile
- *pPORTFIO = 0x0000;
- initInterrupts();
- while(1){
- };
- //*pTIMER_STATUS &= ~(1<<19);
- /* while(1) {
- if((*pTIMER_STATUS&=(1<<19))!=0) {
- i++;
- if(i%2==0)
- *pPORTFIO &= ~(1<<9);
- else
- *pPORTFIO |= (1<<9);
- }
- }*/
- return 0;
- }
- #include <sys/platform.h>
- #include "adi_initialize.h"
- #include "hau.h"
- #include <cdefBF537.h>
- char __argv_string[] = "";
- void config() {
- *pTIMER7_CONFIG |= 1;
- *pTIMER7_CONFIG &= ~(1 << 1);
- *pTIMER7_CONFIG |= (1 << 3);
- *pTIMER7_CONFIG |= (1 << 4);
- *pPORTFIO_DIR |= (1 << 6);
- *pTIMER7_PERIOD = 10000000;
- *pPORTFIO_DIR &= ~(1 << 4); //up
- *pPORTFIO_INEN |= 1 << 4;
- *pPORTFIO_DIR &= ~(1 << 5); //down
- *pPORTFIO_INEN |= 1 << 5;
- }
- int main(int argc, char *argv[])
- {
- volatile unsigned int i;
- adi_initComponents();
- config();
- *pTIMER_ENABLE |= (1 << 7);
- *pTIMER_DISABLE &= ~(1 << 7);
- volatile unsigned sw = 0;
- while(1) {
- if ((*pPORTFIO & (1 << 4))) {
- for (i=0; i<800; i++);
- if ((*pPORTFIO & (1 << 4)) && *pTIMER7_PERIOD != 100000000) {
- while((*pPORTFIO & (1 << 4)));
- *pTIMER_ENABLE &= ~(1 << 7);
- *pTIMER_DISABLE |= (1 << 7);
- *pTIMER7_PERIOD +=
- 0;
- *pTIMER_DISABLE &= ~(1 << 7);
- *pTIMER_ENABLE |= (1 << 7);
- }
- }
- if ((*pPORTFIO & (1 << 5))) {
- for (i=0; i<800; i++);
- if ((*pPORTFIO & (1 << 5)) && *pTIMER7_PERIOD != 2000000) {
- while((*pPORTFIO & (1 << 5)));
- *pTIMER_ENABLE &= ~(1 << 7);
- *pTIMER_DISABLE |= (1 << 7);
- *pTIMER7_PERIOD -= 2000000;
- *pTIMER_DISABLE &= ~(1 << 7);
- *pTIMER_ENABLE |= (1 << 7);
- }
- }
- if ((*pTIMER_STATUS & (1 << 19))) {
- if (sw) {
- *pPORTFIO &= ~(1 << 6);
- sw = 0;
- }
- else {
- *pPORTFIO |= (1 << 6);
- sw = 1;
- }
- *pTIMER_STATUS |= (1 << 19);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement