Beispiel #1
0
void Init()
{
    //-------Oscillator Configuration
    OSCCON=0b01100000;
    OSCTUNE.PLLEN=1;
    //-------AD Configuration
    ANCON0=0;
    ANCON1=0;
    //-------Port Configuration
    porta=0;
    portb=0;
    portc=0;
    portd=0;
    porte=0;
    trisa=0b11010111;
    trisb=0b11000000;
    trisc=0b10111101;
    trisd=0b01110000;
    trise=0b1111;

    //------TMR0
    T0CON=0b10000001; //prescaler 4
    TMR0H=0x63;
    TMR0L=0xBF;
    INTCON.b7=1;
    INTCON.T0IE=1;

    //------LCD Init
    LCD_Init();
    //LCDSystem_Init(&LCD);
    LCD_cmd(_LCD_CURSOR_OFF);
    delay_ms(500);
    LCDBL=1;

    //-------UART
    UART1_Init(9600);
    //UART2_Init(9600);
    RC1IF_bit=0;
    RC1IE_bit=1;
    RC1IP_bit=1;
    PEIE_bit=1;
    UART_Set_Active(&UART1_Read, &UART1_Write, &UART1_Data_Ready, &UART1_Tx_Idle);

    //-------Signaling System
    SignalingSystem_Init(&SigSys);

    //-------Door Status
    DoorStatus=DOORSTATUS_Close;

    //-------LoadConfigs
    LoadConfig();

    //-------RS485
    RS485Slave_Init(NetworkAddress);
}
void genericInit() {

     TRISB = 0;
     CMCON = 0x07;           // Disable comparators
     ADCON1 = 0b00001111;    // All digital
     ADCON0 = 0b00101100;
     UCON.USBEN = 0;
     SSPCON1.SSPEN = 1;      // SDA e SCL porta serial

     UART1_Init(57600);//57600 for 3DR
     UART_Set_Active(&UART1_Read, &UART1_Write, &UART1_Data_Ready, &UART1_Tx_Idle); // set UART1 active

     return;
}