Event module in MSPM0
The Event module in MSPM0 implements autonomous communication between two entities, which include peripherals, DMA or CPU.
Pay special attention to one point: the Event module can also be regarded as a special peripheral, so it can operate independently of the processor (similar to Timer, ADC, OPA, etc.).
The specific event mapping diagram is as follows:
Compared with the general M0 core, TI has integrated a bunch of complex communication modules between CPU, DMA and peripherals into the Event module, which is very convenient to use.
The specific connection examples are as follows:
It can be seen that the common combinations between modules are available. Therefore, common requirements such as timer triggering ADC sampling and UART triggering DMA transfer are all achievable.
Even the publisher and subscriber of an event can be the same type of peripheral. For example, one GPIO can publish an event and another GPIO can subscribe to it. This is the basis for the following case to be implemented.
A case
The main procedure of the case is as follows:
This code does not contain any business logic. It simply configures the board parameters and then enters an infinite loop WFI(). However, the LED can be turned on and off by pressing a button.
What’s even more amazing is that in debug mode, after the debugger triggers the processor to pause, the button’s function of controlling the LED is still valid.
Seeing is believing video demonstration:
This is the function of the Event module: to enable communication between peripherals without processor control.
There are buttons and LEDs on the LaunchPad, all connected to the MSPM0L1306 via GPIO.
You can set the Event from the button to the LED, that is, the GPIO corresponding to the button acts as the Event publisher, and the GPIO corresponding to the LED acts as the Event subscriber.
The set publishers and subscribers will be listed under the EVENT module.
The logic of the button trigger can be rising edge and/or falling edge, here we choose rising edge. The action strategy of LED is to flip IO. Through simple configuration, the event binding between button trigger and LED action can be realized without going through the processor.
Since the Event module is independent of the CPU, the Event module can still operate when the CPU is in debug interrupt state.
summary
The Event module is a featured module of MSPM0. It implements event publishing and subscription through hardware, greatly relieving the burden of the CPU and helping to reduce system power consumption.
Complete code
LaunchPad Main Program
#include "ti_msp_dl_config.h"
int main(void)
{
SYSCFG_DL_init();
DL_SYSCTL_enableSleepOnExit();
while (1) {
__WFI();
}
}
SysConfig Reference Code
/**
* These arguments were used when this file was generated. They will be automatically applied on subsequent loads
* via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments.
* @cliArgs --device "MSPM0L130X" --package "VQFN-32(RHB)" --part "Default" --product "mspm0_sdk@1.20.00.06"
* [url=home.php?mod=space&uid=304333]@versions[/url] {"tool":"1.18.0+3266"}
*/
/**
* Import the modules used in this configuration.
*/
const GPIO = scripting.addModule("/ti/driverlib/GPIO", {}, false);
const GPIO1 = GPIO.addInstance();
const GPIO2 = GPIO.addInstance();
const SYSCTL = scripting.addModule("/ti/driverlib/SYSCTL");
/**
* Write custom configuration values to the imported modules.
*/
GPIO1.$name = "GPIO_LEDS";
GPIO1.port = "PORTA";
GPIO1.portSegment = "Lower";
GPIO1.associatedPins[0].$name = "USER_LED_1";
GPIO1.associatedPins[0].assignedPin = "0";
GPIO1.associatedPins[0].subChanID = 1;
GPIO1.associatedPins[0].subOutputPolicy = "TOGGLE";
GPIO1.associatedPins[0].initialValue = "SET";
const Board = scripting.addModule("/ti/driverlib/Board", {}, false);
GPIO2.$name = "GPIO_SWITCHES";
GPIO2.port = "PORTA";
GPIO2.associatedPins[0].$name = "USER_SWITCH_1";
GPIO2.associatedPins[0].direction = "INPUT";
GPIO2.associatedPins[0].pubChanID = 1;
GPIO2.associatedPins[0].internalResistor = "PULL_UP";
GPIO2.associatedPins[0].interruptEn = true;
GPIO2.associatedPins[0].assignedPin = "14";
GPIO2.associatedPins[0].polarity = "RISE";
GPIO2.associatedPins[0].pin.$assign = "PA14";
SYSCTL.clockTreeEn = true;
/**
* Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future
* version of the tool will not impact the pinmux you originally saw. These lines can be completely deleted in order to
* re-solve from scratch.
*/
GPIO1.associatedPins[0].pin.$suggestSolution = "PA0";
Board.peripheral.$suggestSolution = "DEBUGSS";
Board.peripheral.swclkPin.$suggestSolution = "PA20";
Board.peripheral.swdioPin.$suggestSolution = "PA19";