hw 02 - Interrupts, Parallel Ports, ADC, IOC, PWM.pdf

Ee128 hw 2 3 asmswi this is correct and gnu gcc way

Info icon This preview shows pages 3–5. Sign up to view the full content.

EE128 – HW 2 3 } //asm("swi"); // this is correct and GNU GCC way is below __asm__ __volatile__ ("swi"); // will never get here, given just in case // if debugging with the D-BUG12 is needed return 0; } /**********************************************************************/ /* The following function creates a time delay which is equal to the */ /* multiple of 100 ms. The value passed in Y specifies the number of */ /* 100 milliseconds to be delayed */ /**********************************************************************/ void delayby100ms(int k) { int j,i; TSCR1 |= TFFCA; /* enable fast timer flag clear */ for (i = 0; i < 10; i++) { for (j = 0; j < k; j++) { MCCTL = 0x07; // enable modulus down counter with 1:16 as prescaler MCCNT = 15000; // let modulus down counter count down from 15000 */ while(!(MCFLG & MCZF)); MCCTL &= ~0x04; // disable modulus down counter } } } Listing P1. The C Language equivalent of the ee128 Lab2, Part1 Assembly Code a) What actions will the C compiler undertake when it sees this preprocessor directive: # define OUTPORT 0xFF b) In the Listing P1 inside the main function the variable j has been declared as unsigned short j . Would this code function properly if we had it declared as int j . Why and aexplain also the difference. c) What is the size of the N variable in the code? d) What is the result of this operation (assuming that originally MCCTL contained %10100101) : MCCTL &= ~0x04 . Show the results in both the binary and hex form. e) In the C Language if a variable is not used a compiler will quietly optimize the code so that that variable is be gone from existence. How do we make the compiler keep it? f) What is the results of the compiler processing of the following two lines: #define _IO8(off) *(unsigned char volatile *)(IOREGS_BASE + off) #define DDRH _IO8(0x262) Give a detailed explanation.
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

EE128 – HW 2 4 Review Questions #2 ( Interrupts ) a) (E6.2) †† What are the advantages of using interrupts to handle data inputs and outputs?
Image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.
  • Fall '16
  • Pulse-width modulation, 3F, MCCTL

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern