Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //PROGRAMUL 1
- #include <sys/platform.h>
- #include "BDPN.h"
- #include "adi_initialize.h"
- #include <cdefBF537.h>
- char __argv_string[] = "";
- int main(int argc, char *argv[])
- {
- adi_initComponents();
- *pPORTFIO_DIR = 0x0FC0;
- *pPORTFIO_INEN = 0x0004;
- *pPORTFIO = 0x0000;
- volatile unsigned int i;
- while(1) {
- *pPORTFIO |= (1<<6);
- for(int i = 0; i<=999999 ;i++);
- *pPORTFIO &= ~(1<<6);
- for(int i = 0; i<=999999 ;i++);
- }
- return 0;
- }
- //PROGRAMUL 2
- #include <sys/platform.h>
- #include "BDPN.h"
- #include "adi_initialize.h"
- #include <cdefBF537.h>
- char __argv_string[] = "";
- int main(int argc, char *argv[])
- {
- adi_initComponents();
- *pPORTFIO_DIR = 0x0FC0;
- *pPORTFIO_INEN = 0x0004;
- *pPORTFIO = 0x0000;
- volatile unsigned int i;
- volatile unsigned int k=0;
- while(1) {
- if(*pPORTFIO & (1<<2)) {
- while(*pPORTFIO & (1<<2));
- if(k%2==0){
- *pPORTFIO = (1<<6);
- k++;
- }
- else
- {*pPORTFIO = (0<<6);
- k++;
- }
- }
- }
- return 0;
- }
- //PROGRAMUL 3
- #include <sys/platform.h>
- #include "BDPN.h"
- #include "adi_initialize.h"
- #include <cdefBF537.h>
- char __argv_string[] = "";
- void LIGHT_LEDS(){
- int led_pos = 6; //ultimul led
- *pPORTFIO ^= (1 << led_pos); //ultimul led aprins
- while(1){
- if(*pPORTFIO&0x0008){ //al doilea buton -> o ia in stinga
- while(*pPORTFIO&0x0008);
- if(led_pos == 6){ //daca e deja in capat si apasam stanga o sa aprinda ledul din celalat capat
- *pPORTFIO ^= (1 << 6);
- led_pos = 11;
- *pPORTFIO ^= (1 << 11);
- } else { //daca nu, decrementeaza pozitia
- *pPORTFIO ^= (1 << led_pos);
- *pPORTFIO ^= (1 << led_pos-1);
- led_pos--;
- }
- }
- if(*pPORTFIO&0x0004){ //primul buton -> o ia in dreapta
- while(*pPORTFIO&0x0004);
- if(led_pos == 11){ //daca e deja in capat si apasam dreapta o sa aprinda ledul din celalat capat
- *pPORTFIO ^= (1 << 11);
- led_pos = 6;
- *pPORTFIO ^= (1 << 6);
- } else { //daca nu, incrementeaza pozitia
- *pPORTFIO ^= (1 << led_pos);
- *pPORTFIO ^= (1 << led_pos+1);
- led_pos++;
- }
- }
- }
- }
- int main(int argc, char *argv[])
- {
- adi_initComponents();
- *pPORTFIO_DIR = 0x0FC0;
- *pPORTFIO_INEN = 0x003F;
- LIGHT_LEDS();
- return 0;
- }
- //PROGRAMUL 3
- #include <sys/platform.h>
- #include <sys/exception.h>
- #include <cdefbf537.h>
- #include "adi_initialize.h"
- #include "PNEB.h"
- char __argv_string[] = "";
- void initreg() {
- *pPORTFIO_DIR=0x0FC0;
- *pPORTFIO_INEN = 0x003F;
- *pTIMER7_PERIOD = 25000000;
- *pTIMER7_CONFIG = 0x001D;
- *pTIMER_ENABLE = 0x0080;
- }
- void blinkerino() {
- volatile unsigned int k;
- while(1) {
- if(*pTIMER_STATUS&0x00080000) {
- if(k%2==0) {
- *pPORTFIO= (1<<6);
- k++;
- }
- else
- if(k%2!=0) {
- *pPORTFIO= (0<<6);
- k++;
- }
- }
- *pTIMER_STATUS=0x00080000;
- }
- }
- int main(int argc, char *argv[])
- {
- adi_initComponents();
- initreg();
- blinkerino();
- return 0;
- }
- //PROGRAMUL 4
- #include <sys/platform.h>
- #include <sys/exception.h>
- #include <cdefbf537.h>
- #include "adi_initialize.h"
- #include "PNEB.h"
- char __argv_string[] = "";
- volatile unsigned int k=0;
- EX_INTERRUPT_HANDLER(ISR_Timer7) {
- *pTIMER_STATUS = 0x00080000;
- if(k%2==0) {
- *pPORTFIO = (1<<6);
- k++;
- }
- else
- if(k%2!=0) {
- *pPORTFIO = (0<<6);
- k++;
- }
- }
- void initInterrupts(void) {
- *pSIC_IAR3 = 0xFFFFF5FF;
- *pSIC_IMASK = 0x04000000;
- register_handler(ik_ivg12, ISR_Timer7);
- }
- void initreg() {
- *pPORTFIO_DIR = 0x0FC0;
- *pPORTFIO_INEN = 0x003F;
- *pTIMER7_PERIOD = 25000000;
- *pTIMER7_CONFIG = 0x001D;
- *pTIMER_ENABLE = 0x0080;
- }
- void blinkerino() {
- while(1) {}
- }
- int main(int argc, char *argv[])
- {
- adi_initComponents();
- initInterrupts();
- initreg();
- blinkerino();
- /* DE PE TABLA ?
- volatile unsigned int n, f;
- float t;
- f = 50000;
- t=0.5;
- n=(int) t*f;
- */
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement