Picproje Elektronik Sitesi

MİKRODENETLEYİCİLER => ARM => Konuyu başlatan: Proself - 02 Ekim 2018, 16:42:03

Başlık: STMF072TB Kapasitif Buton Uygulaması
Gönderen: Proself - 02 Ekim 2018, 16:42:03
Merhaba arkadaşlar STM32F072 de touch buton uygulaması yapmak istiyorum.Ancak buton çıkışını analog olarak okumaya çalışsamda adc'de ki değer değişmiyor bu uygulamayı nasıl yapabilirim?Yapmak istediğim uygulama bunun tek ve basit olarak led yakıp söndürme.

video içerisinde ki kod:#include <stm32f10x.h>
#include <stm32f10x_conf.h>

#include <stm32f10x_rcc.h>
#include <stm32f10x_gpio.h>


void Delay(volatile uint32_t nCount)
{
    for (; nCount != 0; nCount--);
}

void Sensor_float (void)
{
GPIOC->CRL = 0x8;
GPIOC->BSRR |= 0x1;
}

void Sensor_pull (void)
{
GPIOC->CRL = 0x1;
GPIOC->BRR |= 0x1;
}

int main(void) {
    /* SystemInit() вызывается из startup_stm32f10x_md_vl.c */

    GPIO_InitTypeDef GPIO_InitStructure;

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC , ENABLE);
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA , ENABLE);

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

    GPIO_Init( GPIOA , &GPIO_InitStructure);


    Sensor_float();
    uint16_t temp=1;
    uint32_t count;

    GPIOC->BRR |= 0x1;

    while (1)
    {
    Sensor_pull();

    count = 0;
    Delay(0xFF);
    Sensor_float();

    while(!((GPIOC->IDR)&0x1))
    {
    count++;
    }

    if(count>1){temp = temp>>1;}
    if(temp == 0b10000000){temp = 1;}
    if(temp == 0){temp = 0b1000000;}
    GPIO_Write(GPIOA,count);
    Delay(0x5FFFF);
    }

    return 0;
}