CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PIC16F628 - DIP SWITCH

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

Re: PIC16F628 - DIP SWITCH
PostPosted: Sat Sep 23, 2006 8:45 pm     Reply with quote

coseglio wrote:
##Urgent## SOS#SOS

Sounds like a homework.

coseglio wrote:
The while(1) loop i want is a infinite loop , but in my program execute only one and stop. I dont know wat is the problem with this.

You're calling getc() in the main loop without calling kbhit() first. It could be that your program waits forever for the input from the serial port. Also, it might help to add something like printf("heartbeat\n\r"); for debugging purposes at the very top or very bottom of the loop outside any if statements. Or to toggle an LED for the same purpose.
Guest








TEST
PostPosted: Sun Sep 24, 2006 7:04 am     Reply with quote

Hi Kender. Thanks for the information.
Can tiy see now that is correct?

Code:
#include <16F628A.h>
#fuses INTRC_IO,NOWDT,PUT,BROWNOUT,NOLVP,NOMCLR
#include "usart.h"
#use delay (clock=4000000)
#use rs232(baud=9600,xmit=PIN_B2,rcv=PIN_B1)
SET_TRIS_A( 0x0F );
SET_TRIS_B( 0x0E );

unsigned char lerDip();

void main(void)
{
   unsigned char saida;
   unsigned char dados;
   unsigned char aux = 0x00;
   unsigned char mascara_a = 0xF0;
   unsigned char entra;
   unsigned char conf_dip;
   int1 fotodiodo;
   unsigned char endereco;

   while(1)

   {
      conf_dip = lerDip(); 
      aux = (conf_dip | mascara_a);
      entra = 0x00;
      entra = kbhit();
       
             
      if(entra);
       {
         dados = getc();
       }   
              if (dados == aux)
              {
         fotodiodo = 0;
         fotodiodo = input(PIN_A0);
             }
           if (fotodiodo)
         {
           saida = 0xFF;
           printf("%c",saida);
         }
           else
          { saida = 0x00;
          printf("%c",saida);
                }
}
       }

unsigned char lerDip()
{
   int8 a1;
   int8 a2;
   int8 a3;
   int8 res;

   res = 0x00;
   
   res |= a1;
   if (a1)
   
   res |= (a2 << 1);
   if (a2)
   
   res |= (a3 << 2);
   if (a3)
   
   return res;
}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group