Program to Divide two 8bit Numbers using PIC18F MCU in MPLAB IDE using Embedded C

Program:

#include <xc.h>

void main(void) 
{
    PORTA = 0x50;  // 80
    PORTB = 0x02;  // 02
    
    TRISA = 0; 
    TRISB = 0;
    TRISC = 0;
    TRISD = 0;
    

    
    PORTD = PORTA%PORTB;  // 80/2 = 40 in 28 Hex 
    PORTC = PORTA/PORTB;
    
    return;
}

Output:



Previous
Next Post »