Inc cblock counter 8 endc movlf macro literal dest

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

View Full Document Right Arrow Icon
#INCLUDE P18f452.inc cblock Counter : 8 endc MOVLF macro Literal, Dest MOVLW Literal MOVWF Dest endm org 0x0000 goto main main rcall Initialize rcall Delay Penguin LFSR 0, Counter loop MOVF INDF0, W MOVWF PORTA MOVF PREINC0, W RCALL Delay BNZ loop MOVF POSTDEC0, W loop2 MOVF POSTDEC0, W MOVWF PORTA RCALL Delay BNZ loop2 goto Penguin Initialize movlw B'11111111' movwf TRISD movlw B'00000000' movwf TRISA MOVLF B'00000000' ,Counter+0 MOVLF B'00000010' ,Counter+1 MOVLF B'00000100' ,Counter+2 MOVLF B'00000110' ,Counter+3 MOVLF B'00001000' ,Counter+4 MOVLF B'00001010' ,Counter+5
Image of page 4

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

View Full Document Right Arrow Icon
MOVLF B'00001100' ,Counter+6 MOVLF B'00001110' ,Counter+7 return Delay MOVLW 6072 / 256 MOVWF TMR0H MOVLW 6072 % 256 MOVWF TMR0L BCF INTCON,TMR0IF MOVLW B'10000001' MOVWF T0CON Loop1 BTFSS INTCON,TMR0IF GOTO Loop1 BCF INTCON,TMR0IF BTFSS PORTD, RD3 GOTO Delay RETURN end Program Code Description The way that the code works is that it makes Port A as an output port and implements a timer into the microcontroller. Also, a counter is implemented into the microcontroller which allows the LED lights to turn on and off depending on what value the counter has. The sequence continues according to the timer and the switch acts as a pause button to the sequence. New Instructions The new set of instructions involved in this lab was to involve a direct and indirect addressing. Also, we were told to completely make up our own codes in order for the lab to be a success. The sequence of the LEDs had to go from 0-7 and backwards. Conclusion There was a problem understanding the concept of macros given in the lab guide. It was easily solved by reading through the guide and the book carefully. The macros are basically shortcuts in the code which reuses a process over and over again without having to type out all of the steps over and over again. The experiment can be improved by making the sequence go backwards or by programming the switch as a permanent pause button so that a person only has to press the button instead of holding it to pause the sequence.
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ 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