EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / How to make PB2 & PB3 pin high in atmega8

How to make PB2 & PB3 pin high in atmega8

|

Microcontroller › AVR › How to make PB2 & PB3 pin high in atmega8

  • This topic has 2 replies, 2 voices, and was last updated 12 years, 4 months ago by nikita.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • January 12, 2013 at 9:52 am #2064
    nikita
    Participant

    Hi all,

     

    I am using Atmega8 in my lighting control application project where i want to make PB1,PB2 & PB3 pin to high.

    But my PB2 & PB3 pin not goes to high,while my PB1 pin make high.
    When  PB2 & PB3 pin make high but when im integrate with touch it will not work.

    Iam using PORTC as a intra port & PORTB-D as a inter port for touch keys & slider.

    port pin confg. for atmega8 is as shown below:

     

    Total Sensors Selected : 6

        Sensor        Channel    SNS,SNSK
        Button0        Channel0    PC0,PC1
        Button1        Channel1    PC2,PC3
        Button2        Channel2    PC4,PC5

        Button3        Channel3    PB0,PD0
        Button4        Channel4    PB4,PD4
        slider0        Channel5    PB5,PD5
        slider0        Channel6    PB6,PD6
        slider0        Channel7    PB7,PD7

    With out integrate the touch with software my PB2, 3 pin goes to high,but when integrate touch with my software PB2, 3 pin not make it high.

    Can any one suggest me the solution over this.

    Thanks.

    January 14, 2013 at 5:54 pm #8957
    AJISH ALFRED
    Participant

    Hi Nikita,

    Suggest you to post your circuit diagram and code so that it will be easy for us to help you out.

    January 15, 2013 at 4:33 am #8959
    nikita
    Participant

    Thanks a lot for your reply.

    For the schematic actually there is no such ckt made because i am working on touch where i made a slider and touch keys on PCB and Resistor and capacitor connection.

    I am using PONYPROG for ISP programming for my atmega8 controller.

     

    Code:

     

    int main( void )
    {
        DDRB = 0xFE;      //PB1,2,3 set as output
       PORTB = 0xFE;    //PB1,2,3 set high

    /*


    Touch Mask


    */

          #define QTOUCH_STUDIO_MASKS    1
        #define NUMBER_OF_PORTS    2

        #define SNS1    C
        #define SNSK1    C

        #define SNS2    B
        #define SNSK2    D

        #ifdef QTOUCH_STUDIO_MASKS    //5key+slider
        SNS_array[0][0]= 0x15;
        SNS_array[0][1]= 0x00;
        SNS_array[1][0]= 0xe1;
        SNS_array[1][1]= 0x10;

        SNSK_array[0][0]= 0x2a;
        SNSK_array[0][1]= 0x00;
        SNSK_array[1][0]= 0xe1;
        SNSK_array[1][1]= 0x10;
        #endif
    /*


    */
       /*disabling all pull ups for touch application*/
        SFIOR |= (1u << PUD);

        /* Configure the Sensors as keys or Keys With Rotor/Sliders in this function */
            config_sensors();

        /* initialise touch sensing */
           qt_init_sensing();

        /*  Set the parameters like recalibration threshold, Max_On_Duration etc in this function by the user */
            qt_set_parameters( );

        /* configure timer ISR to fire regularly */
            init_timer1_isr();
            qt_filter_callback = 0;

      /* enable interrupts */
            __enable_interrupt();

        /* loop forever */
    while(1)
    {  

          if( time_to_measure_touch )
          {
                 SFIOR |= (1u << PUD);
                 read_touch();

           }
        
        {
            get_key();                    //Getting the Status of Sensor
        }
    } //while close

    } //main closed

    static void init_timer1_isr( void )
    {
        /*  set timer compare value (how often timer ISR will fire) */
        OCR1A = ( TICKS_PER_MS * qt_measurement_period_msec);

        /*  enable timer ISR */
        TIMSK |= (1u << OCIE1A);

        /*  timer prescaler = system clock / 8  */
        TCCR1B |= (1u << CS11);

        /*  timer mode = CTC (count up to compare value, then reset)    */
        TCCR1B |= (1u << WGM12);

        /*    Initialize counter for heartbeat       */
        hrtbeat=20;
    }

    ISR(TIMER1_COMPA_vect)
    {
        /*  set flag: it’s time to measure touch    */
        time_to_measure_touch = 1u;

        /*  update the current time */
        current_time_ms_touch += qt_measurement_period_msec;
    //sprintf(“%u/n/r”,current_time_ms_touch);
       hrtbeat–;
        if(hrtbeat==0)
        {
         //PORTC^=(1<<PC6);
         hrtbeat=20;
        }
    }

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Chinese Tarrifs – 104%!?! May 21, 2025
  • An Update On Tarrifs May 21, 2025
  • Tariff Updates from JLCPCB as of Today May 21, 2025
  • Solar lighting motion detector May 21, 2025
  • Telegram Based Alarm - Sensor cable protection May 20, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise