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 / ATmega16 code translation…

ATmega16 code translation…

|

Microcontroller › AVR › ATmega16 code translation…

  • This topic has 2 replies, 2 voices, and was last updated 10 years, 8 months ago by Bahman Mohammadhoseini.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • April 15, 2015 at 6:48 am #3623
    Bahman Mohammadhoseini
    Participant

    Hello,everybody.Would you please tell me;

    1-What does mean the following ATmega16/AVR instructions?;

    ……..

    unsigned int k, h;

    DDRA=0x00;
     
    DDRD=0XFF;
     
    while (1)
    {
     
    k =~PINA;
     
    h=k & 0x0F;
     
    switch (h)
    {…..
     
    And what is the following ATmega16/AVR code translation to PIC18F452 in mikroC compiler ?;
     
    #include <mega16.h>
     
    void main(void)
    {
     
    unsigned int k, h;
     
    DDRA=0x00;
     
    DDRD=0XFF;
     
    while (1)
    {
     
    k =~PINA;
     
    h=k & 0x0F;
     
    switch (h)
    {
     
    case 0x02: 
    {
     
    PORTD=0x89;
     
    break;
     
    }
     
    case 0x08: 
    {
     
    PORTD=0x86; 
     
    break;
     
    }
     
    case 0x04:
    {
     
    PORTD=0x85; 
     
    break;
     
    }
     
    case 0x06:
     
    {
     
    PORTD=0x8A; 
     
    break;
     
    }
     
    case 0x05:
     
    {
     
    PORTD=0x00; 
     
    break;
     
    }
    }
    }
    }
     
                                                                                      Thanks,
     
    April 20, 2015 at 4:45 am #12807
    Vara Ashishkumar
    Participant

    Hey bahman

    DDRA is defined as INPUT port and DDRD is defined as OUTPUT port.DDRx is data direction register which define for initialize I/O pins.PINA register get the readings from input pin of controller.I suggest to you refer the book of AVR controller and PIC controller by mazidi.chek I/O configuration and register of PIC18F452 for AVR atmega16 to PIC18F452 translation.

    April 20, 2015 at 7:29 am #12809
    Bahman Mohammadhoseini
    Participant

    Hi,thanks for your useful answer.

  • 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

  • mechanism to shutdown feeding when sensor temperature rises December 13, 2025
  • Oshonsoft MSSP simulation question December 13, 2025
  • Droplet1 December 13, 2025
  • What is involved to convert a small town to fiber optic? December 13, 2025
  • Measuring controller current output with a meter December 13, 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