Beispiel #1
0
void UAPP_POR_Init_PhaseB( void )
{
    PORTA = UAPP_PORTA_VAL;   // Clear initial data values in port.
    TRISA = UAPP_TRISA_VAL;   // Set port bits function and direction.
    PORTB = UAPP_PORTB_VAL;   // Clear initial data values in port.
    TRISB = UAPP_TRISB_VAL;   // Set port bits function and direction.
    PORTC = UAPP_PORTC_VAL;   // Clear initial data values in port.
    TRISC = UAPP_TRISC_VAL;   // Set port bits function and direction.

//   40-pin parts need setup of PORTD and PORTE.

    #if UCFG_PROC==UCFG_18F452
    PORTD = UAPP_PORTD_VAL;   // Clear initial data values in port.
    TRISD = UAPP_TRISD_VAL;   // Set port bits function and direction.
    PORTE = UAPP_PORTE_VAL;   // Clear initial data values in port.
    TRISE = UAPP_TRISE_VAL;   // Set port bits function and direction.
    #endif

// PIE1 changed: ADIE, RCIE, TXIE, SSPIE, CCP1IE, TMR2IE, TMR1IE disabled.

    PIE1 = UAPP_PIE1_VAL;

// PIR1 changed: ADIF, RCIF, TXIF, SSPIF, CCP1IF, TMR2IF, TMR1IF cleared.

    PIR1 = UAPP_PIR1_VAL;

// PIE2 untouched// EEIE, BCLIE disabled.
// PIR2 untouched// EEIR, BCLIF remain cleared.
//
// IPEN cleared so disable priority levels on interrupts (PIC16 compatiblity mode.)
// RI set// TO set// PD set// POR set// BOR set// subsequent hardware resets will clear these bits.

    RCON = UAPP_RCON_VAL;

// INTCON changed: GIE, PEIE enabled// TMR0IE, INT0IE, RBIE disabled// TMR0IF, INT0IF, RBIF cleared.

    INTCON = UAPP_INTCON_VAL;

//   Global interrupts enabled. The following routines
//   may enable additional specific interrupts.

    UADC_Init();        // User ADC hardware init.

    #if UCFG_PROC==UCFG_18F452
        SLCD_Init();    // System LCD init.
    #endif

    UI2C_Init();        // User I2C hardware init.
    ULCD_Init();        // User LCD init.
    USIO_Init();        // User Serial I/O hardware init.
}
Beispiel #2
0
int main(void)
{
    uint8_t waveForm = 0;
    slcd_config_t config;
    slcd_clock_config_t clkConfig =
    {

        kSLCD_AlternateClk1,   //  MCGIRCLK  wenxue

        kSLCD_AltClkDivFactor256, // MCGIRCLK =8M  8M/256=32.15k

        kSLCD_ClkPrescaler01,    // wenxue  LCLK=1
			
#if FSL_FEATURE_SLCD_HAS_FAST_FRAME_RATE
        false
#endif
    };

    /* Hardware initialize. */
    BOARD_InitPins();  // wenxue 要修改
		
    BOARD_BootClockRUN();
		
    BOARD_InitDebugConsole();
		
    /* Enable the MCGIRCLK */
    MCG->C1 |= MCG_C1_IRCLKEN_MASK;

    PRINTF("\r\nSLCD Example Starts.\r\n");

    /* SLCD get default configure. */
    /*
     * config.displayMode = kSLCD_NormalMode;
     * config.powerSupply = kSLCD_InternalVll3UseChargePump;
     * config.voltageTrim = kSLCD_RegulatedVolatgeTrim00;
     * config.lowPowerBehavior = kSLCD_EnabledInWaitStop;
     * config.frameFreqIntEnable = false;
     * config.faultConfig = NULL;
     */
    SLCD_GetDefaultConfig(&config);

    /* Verify and Complete the configuration structure. */
    config.clkConfig = &clkConfig;
    config.loadAdjust = kSLCD_HighLoadOrSlowestClkSrc;
    config.dutyCycle = kSLCD_1Div4DutyCycle;
		
		/*  全部LCD 引脚配置 */
    config.slcdLowPinEnabled =  0xFFF0FF7FU;        /* LCD_P14/15/20/24/26/27 相应位置为1   */
    config.slcdHighPinEnabled = 0x00000F80U;        /* LCD_P8/10/11/12/27/28+32= LCD_P40/42/43/44/59/60.  相应位置为1 */
		
		/* COM 口配置 */
    config.backPlaneLowPin =  0x0000010EU;    /* LCD_P1/2/3/8 */
    config.backPlaneHighPin = 0x00000000U;   /*  */
    config.faultConfig = NULL;
		
    /* SLCD Initialize. */
    SLCD_Init(LCD, &config);

   /* Set SLCD front plane phase to show: all segments on . */
    waveForm = (kSLCD_PhaseAActivate | kSLCD_PhaseBActivate | kSLCD_PhaseCActivate | kSLCD_PhaseDActivate);
    /* Set SLCD back plane phase. */  /*  COM 口 wenxue   */
    SLCD_SetBackPlanePhase(LCD, 1, kSLCD_PhaseAActivate); /* SLCD COM1 --- LCD_P1. */
    SLCD_SetBackPlanePhase(LCD, 2, kSLCD_PhaseBActivate); /* SLCD COM2 --- LCD_P2. */
    SLCD_SetBackPlanePhase(LCD, 3, kSLCD_PhaseCActivate); /* SLCD COM3 --- LCD_P3. */
    SLCD_SetBackPlanePhase(LCD, 8, kSLCD_PhaseDActivate); /* SLCD COM4 --- LCD_P8. */
		
		
		
    /* Set SLCD front plane phase to show. */    /*  Seg 口 wenxue   */
    SLCD_SetFrontPlaneSegments(LCD, 20, waveForm); /* SLCD P05 --- LCD_P20. */
    SLCD_SetFrontPlaneSegments(LCD, 24, waveForm); /* SLCD P06 --- LCD_P24. */
    SLCD_SetFrontPlaneSegments(LCD, 26, waveForm); /* SLCD P07 --- LCD_P26. */
    SLCD_SetFrontPlaneSegments(LCD, 27, waveForm); /* SLCD P08 --- LCD_P27. */
    SLCD_SetFrontPlaneSegments(LCD, 40, waveForm); /* SLCD P09 --- LCD_P40. */
    SLCD_SetFrontPlaneSegments(LCD, 42, waveForm); /* SLCD P10 --- LCD_P42. */
    SLCD_SetFrontPlaneSegments(LCD, 43, waveForm); /* SLCD P11 --- LCD_P43. */
    SLCD_SetFrontPlaneSegments(LCD, 44, waveForm); /* SLCD P12 --- LCD_P44. */

    /* Starts SLCD display. */
    SLCD_StartDisplay(LCD);
    PRINTF("\r\nSLCD Displays All Segments.\r\n");
    SLCD_TimeDelay(0xFFFFFFU);

    PRINTF("\r\nSLCD Starts Blink Mode.\r\n");

    /* Blink mode Display. */
    SLCD_StartBlinkMode(LCD, kSLCD_BlankDisplayBlink, kSLCD_BlinkRate01);
    SLCD_TimeDelay(0xFFFFFFU);

    PRINTF("\r\nSLCD Stops Blink Mode.\r\n");
    /* Stops SLCD blink display mode. */
    SLCD_StopBlinkMode(LCD);
    SLCD_TimeDelay(0xFFFFFFU);

    PRINTF("\r\nSLCD Stops Display.\r\n");
    /* Stops SLCD display. */
    SLCD_StopDisplay(LCD);

    PRINTF("\r\nSLCD Example Ends.\r\n");

    while (1)
    {
    }
}