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 / pic16f917…..program code query

pic16f917…..program code query

|

Microcontroller › PIC › pic16f917…..program code query

  • This topic has 1 reply, 1 voice, and was last updated 12 years, 8 months ago by Rahul.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • May 10, 2013 at 12:05 pm #4818
    Rahul
    Participant

    I have written this code and i am getting an unexpected error. while debugging i noticed that the Variable “num”, ihave initialised is not same. Consider the Picture, which is in the end.

     

    Here is my program,

     

    #include<16f917.h>
    #fuses HS
    #use delay(clock=20000000)
    #use standard_io(d)
    #use standard_io(b)
     
    #byte trisb=0x86
    #byte portb=0x06
    #byte trisd=0x88
    #byte portd=0x08
     
     
    void ssd(unsigned int16);
    void disp(unsigned int16);
    unsigned int16 num=0x1234;
     
     
    void main()
    {
       trisd=0x00;
       trisb=0x00;
       portd=0x00;
       portb=0xfe;
     
       for(;;)
       {
          //unsigned int16 number=0x1234;
          //number= 0x1234;
          ssd(num);
       }
    }
     
     
    void ssd(unsigned int16 data)
    {
       unsigned int16 value1=0x0000, value2=0x0000, value3=0x0000, value4=0x0000;
       value1 = data & 0xf000;
       value2 = data & 0x0f00;
       value2 = value2<<4;
       value3 = data & 0x00f0;
       value3 = value3<<8;
       value4 = data & 0x000f;
       value4 = value4<<12;
       output_low(pin_b1);
       disp(value1);
       output_high(pin_b1);
       delay_us(500);
       output_low(pin_b2);
       disp(value2);
       output_high(pin_b2);
       delay_us(500);
       output_low(pin_b3);
       disp(value3);
       output_high(pin_b3);
       delay_us(500);
       output_low(pin_b4);
       disp(value4);
       output_high(pin_b4);
       delay_us(500);
    }
     
     
    void disp(unsigned int16 temp)
    {
       unsigned int16 x=0x0000;
       x=temp;
       switch(x)
       {
          case 0000 : portd= 0xc0;
                   break;
     
          case 1000 : portd= 0xf9;
                   break;
     
          case 2000 : portd= 0xa4;
                   break;
     
          case 3000 : portd= 0xb0;
                   break;
     
          case 4000 : portd= 0x99;
                   break;
     
          case 5000 : portd= 0x92;
                   break;
     
          case 6000 : portd= 0x82;
                   break;
     
          case 7000 : portd= 0xf8;
                   break;
     
          case 8000 : portd= 0x80;
                   break;
     
          case 9000 : portd= 0x98;
                   break;
     
          default : portd= 0x00;
                   break;
       }

    }.

     

     

     

     

     

     

    May 10, 2013 at 12:09 pm #9702
    Rahul
    Participant

    wysiwyg_imageupload:8479:

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

RSS Recent Posts

  • Variable audio oscillator January 17, 2026
  • Sine wave distortion January 17, 2026
  • My Advanced Realistic Humanoid Robots Project January 17, 2026
  • Micro mouse January 17, 2026
  • flexible copper cable January 16, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 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