viernes, 18 de mayo de 2018


BTFSS INSTRUCTION  IN ASSEMBLER FOR PIC18F


In this sample, we show that how to use a switch input to make an action.
Remember that I can teach you or help you in your projects. If you interested please ask at:
postgraduatecahg@gmail.com



list p=18f2550
include "P18F2550.INC"
  ;Bits de configuration
        CONFIG FOSC = HS 
        CONFIG PWRT = OFF                  ; Power-up Timer OFF
        CONFIG BOR = OFF                     ; Brown-out OFF
        CONFIG WDT = OFF;
        CONFIG MCLRE = ON
        CONFIG PBADEN = OFF
        CONFIG LVP = OFF
        CONFIG DEBUG = OFF
        CONFIG XINST = OFF
        
; CODE ******************************************************
#define Led PORTB, 4
ORG  0x00
; start from 0x00 address
GOTO START
;jump to start label.
ORG  0x50 ; space for IRS
START
MOVLW 0x0F;
MOVWF TRISA
CLRF  PORTB; PORTB = 0x00
CLRF TRISB;
MOVLW 0x0F;
MOVWF ADCON1
LOOP
BTFSS PORTA,0;skip next instruction if RB0 = 1 
GOTO LEDOFF;    RB0 = 0, 
BSF Led;    LED is on now
BRA LOOP   ; Branch to START
LEDOFF
BCF Led;    LED is OFF.
BRA START
END;END of program.


You can ask by my course in Spanish.






Microcontrollers PIC18F course second sample using assembler


This is the second sample of my course if you interested in the course or you need help in a project (not for free) you can contact me at:
postgraduatecahg@gmail.com



list p=18f2550
  include "P18F2550.INC"
  ;Bits de configuracion
        CONFIG FOSC = HS 
; High speed clock.
        CONFIG MCLRE = OFF                ; Master Clear OFF
        CONFIG BOR = OFF                     ; Brown-out OFF
        CONFIG PWRT = OFF                  ; Power-up Timer OFF
        CONFIG LVP = OFF
        CONFIG XINST = OFF
        CONFIG PBADEN = OFF
        CONFIG CP0 = OFF
        CONFIG CP1 = OFF
        CONFIG CP2 = OFF
        CONFIG CP3 = OFF
        CONFIG CPB = OFF
        CONFIG CPD = OFF
ORG  0x00
; start from 0x00 address
GOTO START
;jump to start label.
ORG  0x50 ; space for IRS
START
movlw 0x0F; 
movwf ADCON1,0 
;PORTAandPORTB pins are digitals
clrf TRISB,0 
;PORT B as an output.
movlw b'00011111';
movwf TRISA,0
;PORT A as input
LOOP
movf  PORTA,W,0  
;Move Port A and store it in W.
andlw  0x0F    
;W = W(AND)00001111
movwf  PORTB,0; 
goto  LOOP; for make a loop
end; END of the program.




Figure 1. Circuit diagram. 


You can ask by my course in Spanish.




jueves, 17 de mayo de 2018





GET STARTED WITH PIC18F2550 PROGRAMMING IN ASSEMBLER AND BIT CONFIGURATION







In this post, I want to share how to write a program in assembler to get started with PIC18F2550 and MPLAB X.

The program can be segmented into 3 parts. The First part is PIC selection through the list and include reserved words.
The second part of the program is the bit configurations.
Finally, the 3rd part of the program is the application program. In this sample, I only get a toggle in the PORT RC0.

Enjoy your first program and please remember that I can teach you or help you with your projects, you can contact me at:
postgraduatecahg@gmail.com





list p=18f2550
include "P18F2550.INC"
   
 CONFIG FOSC = HS ;HS crystal oscilator 8MHz
 CONFIG MCLRE = ON ; enable Master Clear
 CONFIG BOR = OFF ;Brown-out OFF
 CONFIG PWRT = OFF; Power-up Timer OFF
 CONFIG LVP = OFF ;Low-Voltage programming disabled (necessary for debugging) 
 CONFIG WDT = OFF ;disable watchdog timer
 CONFIG PBADEN = OFF ;This is to confing ADC converter check the datasheet
 CONFIG CP0 = OFF ;No code protection  
 CONFIG CP1 = OFF;
 CONFIG CP2 = OFF;
 CONFIG CP3 = OFF;
 CONFIG CPB = OFF;
 CONFIG CPD = OFF;

 ORG 0x00
 GOTO START
 ORG 0x50

 START
    CLRF PORTC ; Clear PORTC.
    CLRF TRISC ; PORTC is confired as outputs.
 MAIN
    BTG PORTC, RC0 ; RC0 Bit toggle.
    GOTO MAIN ; Goto to main address.
    END
 
 

For further information about the bit configuration, you can search in the datasheet and in the next link.

https://openlabpro.com/guide/configuration-bits-for-pic18f4550/





BTFSS INSTRUCTION  IN ASSEMBLER FOR PIC18F In this sample, we show that how to use a switch input to make an action. Remember that I...