Buzzer-driven learning

Source: Internet
Author: User

Buzzer Driver

Buzzer points DC and the Communication two kinds, so-called DC buzzer is the addition of a voltage can ring, The AC buzzer is actually the equivalent of a loudspeaker, directly added to the DC will not make a sound or low voice, need an external pulse to work normally, this pulse can be a square wave, or a piece of music, this signal is an AC signal .

The mini2440 buzzer connection diagram is as follows:

It looks like this is an AC buzzer, so a PWM driver is required.

Before you do this, you'll introduce several functions:

S3C2410_GPB

If the lowest bit offset of the GPIOA is 0, the overall S3C2410_GPB is the offset of each pin in B relative to the GPIOA lowest bit.

S3c2410_gpio_cfgpin

Usage:

S3c2410_gpio_cfgpin (S3C2410_GPB (0), s3c2410_gpio_output);

Function:

Function of this function is to configure the function of IO port.

Source:

Tangled up one night, the original mystery is in the s3c24xx_gpio_base.

S3c24xx_gpio_base directly according to the port number to calculate its corresponding virtual address, too NB, do not map it? Here's a look at the source code:

As can be seen, according to the pin corresponding to the register offset calculation of its virtual address, where the 0xf4000000 is a long-established address, my understanding is the initialization of this and after this section of the address has been mapped to the physical memory, now directly use the good.

Here is a problem, that is, the 3g-3g+896m range is direct mapping, my understanding is the direct mapping area of the maximum 896M, here should be less than 896M, the remainder is allocated to the dynamic memory map area, That is to say, the 0xf4000000 and the next piece are actually dynamically mapped to the 0x51000000 (almost the number). ) about the physical memory.

The great God is as follows:

S3c2410_gpio_setpin

Usage:

S3c2410_gpio_setpin (S3C2410_GPB (0), 0);

Function:

Pull the IO port higher or lower.

IOctl's command constructs:

In fact, the IOCTL command is the number, but in order to prevent your driver accidentally open other files Results command happens to be on the, the IOCTL command is divided into the following parts:

1. Magic Number: Frankly speaking, different drivers use the magic number should be different

2. serial number, the sequence number of the command in your own driver

3. Data Flow, if you want to pass the parameter, it involves the data flow

4. Data Size

C MD is constructed in the following ways:

_io (TYPE,NR)//command with no parameters

_ior (type,nr,size)//The command reads data from the drive

_iow (type,nr,size)//The command is written from the driver to the data

_IOWR (type,nr,size)//bidirectional data transmission

The macro that extracts the parameters from CMD is as follows:

_ioc_dir (CMD)//extract direction from command

_ioc_type (CMD)//Extract magic number from command

_IOC_NR (CMD)//extract ordinal from command

_ioc_size (CMD)//Extract data size from command

Hybrid Device Drivers

Automatic generation of device files, initializing

set up the PWM process

1. Setting the Prescaler Register (TCFG0)

2. Set the split value (split again on the basis of the Prescaler) (TCFG1)

3. Set the value of the counter (TCNTB)

4. Set duty ratio (TCMPB)

5. Set the control register to auto reload, and then manually update it once (the values in TCNTB and TCMPB load tcnt, TCMP), turn on the timer (TCON)

6. Turn off manual updates (TCON)



From for notes (Wiz)

Buzzer-driven learning

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.