AN3301 Software
Doc ID 18161 Rev 1 31/35
/*Checking the bit 3(P1 bit) value from Interrupt status register goes high*/
if ((Touch_Data [0] & 0x08) == 0x08)
{
/*Getting the12 bits ADC data from the ADC Data Register (0x21 & 0x22) */
STMPE812A_GetADCData (&adcdata);
/*Printing the received “adcdata” value on the monitor screen*/
printf ("%ld\n\r", adcdata);
/*Starting the ADC Conversion (Initiate Data Acquisition by setting the bit [6]) in
the ADC Control Register (0x20)*/
STMPE812A_StartADC (TRUE);
}
}
}}
Software AN3301
32/35 Doc ID 18161 Rev 1
2.6.5 PWM initialization and interrupt handling
The following is an example for PWM initialization and interrupt servicing routine.
A: Initialization
void STMPE812A_PWM_Initialization (void) {
/*Enabling the Soft Reset in the System Control Register (0x03)*/
STMPE812A_SoftReset ();
/*Enabling the PWM and GPIO Clocks in the System Control Register (0x03)*/
STMPE812A_SetClock (STMPE812A_ENABLE, STMPE812A_PWM_CLK|STMPE812A_GPIO_CLK);
/*Setting the Port - 2 as a special function in the Port Function Control Register
(0x04)*/
STMPE812A_SetPortFunction (STMPE812A_PORT2, STMPE812A_PORT_FUNC_SPECIAL_FUNC);
/*Setting the Port - 1 as a special function in the Port Function Control Register
(0x04)*/
STMPE812A_SetPortFunction (STMPE812A_PORT1, STMPE812A_PORT_FUNC_SPECIAL_FUNC);
/*Setting the Burst_Length [1:0] as ‘8mS’ in the PWMClockDiv Register (0x50) */
STMPE812A_SetPWMBurstLengh (STMPE812A_PWM_BURSTLENGTH_8MS);
/*Setting the Div [4:0] value as ‘0’ in the PWMClockDiv Register (0x50)
respectively*/
STMPE812A_SetPWMClockDivider (0);
/*Setting the Brightness [7:4] as ‘Duty Cycle Ratio 8: 8 (50.00%)’, BurstMultiplier
[3:2] value as ‘1’ and Off_State [1] as ‘PWM Output “LOW” when PWM not running’ in
the PWMControl1 Register (0x51) respectively*/
STMPE812A_ConfigurePWM (STMPE812A_PWM_DUTY_CYCLE_50_00, 1,
STMPE812A_PWM_OFF_STATE_HIGH);
/*Setting the INT_Mode [7] as ‘Normal Interrupt Mode’ in the Interrupt Control
Register (0x08)*/
STMPE812A_SetInterruptMode(STMPE812A_INT_MODE_NORMAL);
/*Setting the INT_Type [1] as ‘Level Interrupt Type’ in the Interrupt Control
Register (0x08)*/
STMPE812A_SetInterruptType (STMPE812A_INT_TYPE_LEVEL);
/*Enabling the Global Interrupt in the Interrupt Control Register (0x08)*/
STMPE812A_EnableGlobalInterrupt (TRUE);
AN3301 Software
Doc ID 18161 Rev 1 33/35
/*Enabling the interrupt from the system related source of P1 to the host in the
Interrupt Enable Register (0x09)*/
STMPE812A_EnableInterrupt (STMPE812A_INT_P1, TRUE);
/*Enabling the PWM Controller Sequence in the PWMControl1 Register (0x51)*/
STMPE812A_EnablePWM (TRUE);
}
B: Interrupt handling
void IRQHandler (void) {
if (GetITStatus (INTERRUPT_LINE)! = RESET)
{
/*Clearing the Interrupt pending bit from the Micro-controller*/
ClearITPendingBit (INTERRUPT_LINE);
/*Checking the Interrupt Pin Status goes low*/
while ((GPIO_INTERRUPT->IDR & GPIO_PIN_INTERRUPT) == 0)
{
/*Reading the Interrupt status register*/
STMPE812A_GetInterruptStatus (&Touch_Data [0]);
/*Checking the bit 3(P1 bit) value from Interrupt status register goes high*/
if ((Touch_Data [0] & 0x08) == 0x08)
{
/*Enabling the PWM Controller Sequence in the PWMControl1 Register (0x51)*/
STMPE812A_EnablePWM (TRUE);
}
}
}}

STMPE812ABJR

Mfr. #:
Manufacturer:
STMicroelectronics
Description:
Touch Screen Controllers Touchscreen cntrlr S-Touch
Lifecycle:
New from this manufacturer.
Delivery:
DHL FedEx Ups TNT EMS
Payment:
T/T Paypal Visa MoneyGram Western Union

Products related to this Datasheet