3 clean and build main project 4 make sure you have

This preview shows page 8 - 12 out of 15 pages.

We have textbook solutions for you!
The document you are viewing contains questions related to this textbook.
Finite Mathematics and Applied Calculus
The document you are viewing contains questions related to this textbook.
Chapter 7 / Exercise 61
Finite Mathematics and Applied Calculus
Costenoble/Waner
Expert Verified
3.)Clean and Build Main Project 4.)Make sure you have “Simulator selected” 5.)Add a breakpoint on your wait() function call. 6.)Simulate your program. It should look something like this: Example of 24-bit pulse train showing the color #004000, utilizing C with ASM functions 7.)Switch to your programmer and program your PIC24. Hopefully your iLED changes color! Page 8
We have textbook solutions for you!
The document you are viewing contains questions related to this textbook.
Finite Mathematics and Applied Calculus
The document you are viewing contains questions related to this textbook.
Chapter 7 / Exercise 61
Finite Mathematics and Applied Calculus
Costenoble/Waner
Expert Verified
EE 2361 - Lab # 2bECE DepartmentPre-Lab DeliverablesC Program that contains boilerplate, setup(), endless loop in main(), and when run correctly sets the color of your iLED The following ASM function are accessible in your C program: void wait_100us(void); void wait_1ms(void); void write_0(void); void write_1(void);Pre-Lab ChecklistTake pre-lab quiz Complete the walk-through to create a mixed C and ASM project in MPLAB X Bring to lab a single assembly project that fulfills the Pre-Lab Deliverables Page 9
EE 2361 - Lab # 2bECE DepartmentLab ProcedureDuring this lab you will create support C code to make your iLED shine. Create a decoder functionThe first component needed is a decoder function that will translate three 8-bit color values into 24 consecutive calls to write_0()or write_1(). The typical method used for this type of serialization of data is called “mask and shift”, but there are many ways to implement it. You will have to choose a method and implement it. Finally, don’t forget to hold the output low for >50us to latch the data into the iLED (wait_100us();) 1.)Write a function that does the above with the following declaration: void writeColor(int r, int g, int b); 2.)Run a simulation of your “hardcoded” color loop() function, look at the resulting output on the Logic Analyzer. QUESTION: How many cycles does your hard coded program take to write 24-bits? 3.)Replace the hard-coded calls to write_0(), write_1(), and wait_100us()with your new writeColor()function. 4.)Simulate your new function. QUESTION: How many cycles does your new function take to write 24-bits? 5.)Verify your new function operates correctly in hardware. Page 10
EE 2361 - Lab # 2bECE DepartmentImplement color cycler functionIt is time to create our first animation! We need to decide on the sequence for our animation. One option is to create a continuous change from one color to another (often called a gradient). Example of a gradient Mathematically this is described by the following pseudo-code: assumebyteFrameNumber {0, …, 255} byteRed = byteFrameNumber; byteBlue = 255 - byteFrameNumber; 1.)Write a program that uses the pattern above to display Red -> Purple -> Blue -> Purple -> Red and repeats. Keep in mind, after each color change you will need to delay for the user to observe the color. Use your delay of 1ms for this purpose. 2.)When your code compiles successfully, load it on your PIC24 and test it out. Due to the difference between human and machine perception rates, it is useful to control the rate of an animation with a compiler constant. 3.)Create a compiler constant: #define PERIOD 5 (where the period of blinks is PERIOD, in milliseconds) 4.)Write a new C function that calls your ASM function wait_1ms()a variable number of times (this doesn’t have to be exactly N milliseconds, some overhead is ok): void delay(int delay_in_ms) 5.)Utilize the above constant and the new delay function to make your program easily

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture