5, CC2541 Chip Intermediate tutorial-osal operating system (pwm+ watchdog)

Source: Internet
Author: User

This article is based on a week CC2541 notes summary

Suitable for overview and quick index of knowledge--

All Links:

Intermediate Tutorial-osal Operating system \osal operating system-a preliminary study of experimental osal

"Insert" sourceinsight-Engineering Establishment method

Intermediate Tutorial-osal Operating System (Osal System solution basic routines)

Intermediate Tutorial-osal Operating system (learn more about-oled && normal keys and 5-directional buttons-interrupts!!!) This system drive layer is not the same as the application layer ~

Intermediate Tutorial-osal Operating system (adc-photoresistors)

Osal Operating System-experiment 16 serial port baud rate extension

Osal operating system-experimental at command preliminary

Osal operating System-experimental 20 simulated IIC communication + hardware IIC (Mpu6050)

Osal operating system-experimental PWM output (change duty duty)

Osal Operating System-Lab 24 watchdog Wachdog

Osal operating System-experimental SNV internal flash data Read and write

Osal Operating System-experimental 29 system sleep level study

Osal Operating System-experiment 31 slave broadcast power modification

One, PWM output (change duty ratio) at

Common is the use of Bluetooth control cc2540 or cc2541 output PWM adjustment RGB lamp, to achieve a variety of color adjustment

Implement P0.3, P0.4, P0.5, output 3-way PWM, generally this PWM, can realize the control of RGB color bulb.

The above 2 files, the realization is the PWM initialization and the interrupt and the setting.

Defining 3-Way Pins

The above is the setting of the PWM initialization, here, the set cycle of the tick is 375, that is, 1.5ms period.

The interrupt function for time

Want to control the duty ratio can call Pwm_pulse to modify (Red,green,blue to its value)

is achieved by assigning these parameters to the comparison register.

at the application level:In simplebletest.c second, watchdog Wachdog There are generally two types of watchdog functions:
    • First, the prevention program flies, when the system program runs after the system automatically restarts, to avoid the entire large system to stop running or crash.
    • Second, this is the most commonly used, it is necessary to use the software restart, for example, we set some parameters to expect the system to restart, this time the watchdog can also come in handy.

Hal_mcu.h

TI has done a part of the watchdog code, but timed 1000ms the watchdogNo, we add this feature: 144 Line, the system resets, in effect, starts the watchdog, and then does not feed the dog for a reboot.
line , we realize the start of 1000MS timer watchdog, 1000ms need to feed the dog, otherwise it will restart.
#define HAL_SYSTEM_WATCH_DOG_1000MS () st (wdctl = 0x00; Wdctl |= 0x08; ) Type of code we added.216 lines, feed the dog, avoid software restart
225 Line, timing 1000ms, 1000ms need to feed the dog, or restart the
235 lines, is intentional system restart Summary: Watchdog also has the function of automatic restart!!! The protocol stack is well packaged and can be called directly! Relay Tutorial Data Link: http://pan.baidu.com/s/1o6Olppg Intermediate Tutorials Finish ~

5, CC2541 Chip Intermediate tutorial-osal operating system (pwm+ watchdog)

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.