Here is the basic program you need to start off with when you learn to use a microcontroller. We are using the microchip family PIC microcontroller. Which stands for Peripheral Interface Controller, PIC 18F452 is a 40 pin 8-bit microcontroller with 32 KBytes flash, 1536 Bytes of RAM and 256 Bytes EEPROM. It also boasts 4 timers, and three external interrupt pins.
Coming to our first program, We will be using MPLAB for Building this project. Create a new project and select MPASM Suite for compiling. After writing the program, Dont forget to add the linker file and the source file in the source window. The linker file for the PIC 18F452 can be found in the C:\Program Files\Microchip\MPASM Suite\LKR. search for 18f452.
In this program, the Bit RB0, toggles continuously with some delay. Connect an LED to The RB0 Pin, i.e Pin 33.connect a 330E resistor in series with the LED.
PROGRAM
#INCLUDE p18f452.INC;
CONFIG WDT=OFF; disabling the watchdog timer
ORG 0; Specifing the starting memory location
BCF TRISB,0 ; Making PORTB as output
BSF PORTB,0 ;Making PORTB Pin 0 (RB0) as high
HERE BTG PORTB,0 ; toggles the RB0 1/0
CALL DELAY ; calls for the Delay subroutine, for the led to blink
GOTO HERE
DELAY MOVLW 0x0ff
MOVWF 0x10
AGAIN DECFSZ 0x10
GOTO AGAIN
RETURN
END
Coming to our first program, We will be using MPLAB for Building this project. Create a new project and select MPASM Suite for compiling. After writing the program, Dont forget to add the linker file and the source file in the source window. The linker file for the PIC 18F452 can be found in the C:\Program Files\Microchip\MPASM Suite\LKR. search for 18f452.
In this program, the Bit RB0, toggles continuously with some delay. Connect an LED to The RB0 Pin, i.e Pin 33.connect a 330E resistor in series with the LED.
PROGRAM
#INCLUDE p18f452.INC;
CONFIG WDT=OFF; disabling the watchdog timer
ORG 0; Specifing the starting memory location
BCF TRISB,0 ; Making PORTB as output
BSF PORTB,0 ;Making PORTB Pin 0 (RB0) as high
HERE BTG PORTB,0 ; toggles the RB0 1/0
CALL DELAY ; calls for the Delay subroutine, for the led to blink
GOTO HERE
DELAY MOVLW 0x0ff
MOVWF 0x10
AGAIN DECFSZ 0x10
GOTO AGAIN
RETURN
END
Comments
Post a Comment