This article is a mirror article of machine translation, please click here to jump to the original article.

View: 9602|Reply: 0

Four-position flow lamp cycle flashing method

[Copy link]
Posted on 11/15/2014 8:54:46 PM | | |
1: Experiment name
      Four-digit running lamp

2: Experimental content
Realize the cycle of flashing the four-position running lamp

3. Purpose of the experiment
1: Master the LED hardwarecircuit
2: Master the register configuration method of KL25 GPIO module output
3: Master the programming method of four-digit running light cycle flashing

4. Experimental methods
      1: Consult the circuit diagram of that section
           It was found that the PTB8, PTB9, PTB10, and PTB11 pins of KL25 control the four LED light-emitting diodes D6, D7, D8, and D9 respectively.
file:///C:\Users\AA\AppData\Local\Temp\ksohtml\wps_clip_image-3968.png
     2: Configure the corresponding registers of the GPIO module
(1) Refer to page 122 of the KL25 Reference Manual and find that the GPIO is provided by the platform clock.

(2) Connect the Platform clock clock and the POTRB module, and program it as follows:  
            SIM_SCGC5=SIM_SCGC5_PORTB_MASK; SIM_SCGC5 registers can be consulted

(3) Set the multiplexing pin attributes, configure PTB8, PTB9, PTB10, and PTB11 as GPIO functions, and program them as follows:
PORTB_PCR8=PORT_PCR_MUX(1);
PORTB_PCR9=PORT_PCR_MUX(1);
PORTB_PCR10=PORT_PCR_MUX(1);
PORTB_PCR11=PORT_PCR_MUX(1);
Refer to the PORTx_PCRn register and page 46 of the KL25 Data Sheet for more information

      (4) Set the input and output direction of the pins, set PTB8, PTB9, PTB10, and PTB11 to output, and program them as follows:
          GPIOB_PDDR=GPIO_PDDR_PDD(0x00000f00u); GPIOx_PDDR registers can be consulted

(5) Set the output logic level of the pin, set the output high level of PTB8, PTB9, PTB10, PTB11, and program it as follows:
GPIOB_PDOR=GPIO_PDOR_PDO(0x00000f00u); Consult GPIOx_PDOR registers

3: Realize the cycle flashing of the four-position running lamp
[mw_shl_code=c,true]Consult the corresponding program in the main function of the routine/*
***********************************************************
*  file name : main.c
*  function  : function for main
*  
***********************************************************
*/

#include "derivative.h"
#include "config.h"
#include "crg.h"
#include "gpio.h"



/******************************主函数*************************************/
int main(void)
{
  asm(" CPSID i");  The general interruption of the pass
         
  crg_default_init();  System default clock
  //crg_configuration_init();  Clock after configuration
  MCGIRCLK_outenable();  Enables MCGIRCL output 2M
  clock_test(4);  Tests of the corresponding clocks

  gpio_init();  GPIO initialization

  asm(" CPSIE i");  Open the total interruption

  for(;; )
  {         
    GPIOB_PDOR=GPIO_PDOR_PDO(0x00000100u);  PTB8 output high level, D6LED light on
        delayms(15000);  Delay
        GPIOB_PDOR=GPIO_PDOR_PDO(0x00000200u);  PTB9 output high level, D7LED light on
        delayms(15000);  Delay
        GPIOB_PDOR=GPIO_PDOR_PDO(0x00000400u);  PTB10 output high level, D8LED light on
        delayms(15000);  Delay
        GPIOB_PDOR=GPIO_PDOR_PDO(0x00000800u);  PTB11 output high level, D9LED light on
        delayms(15000);  Delay
  }
               
}[/mw_shl_code]





Previous:The difference between EEPROM, EPROM, FLASH, SRAM, DRAM, SDRAM and SDRAM
Next:Win7 system blue screen code large collection
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com