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 CCS Technical Support

Output D problem

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



Joined: 21 May 2015
Posts: 181

View user's profile Send private message

Output D problem
PostPosted: Fri Jan 22, 2016 2:58 am     Reply with quote

Hai, I'm having trouble when I type 12345678 result at output D only D4,D5,D6 and D7 become high, D1,D2,D3,D4 will become low. Suppose all Output D will become High. What cause this problem ?


Code:


#include <18F4550.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN 

#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
#include <stdlib.h>
#include <input.c>
#include <string.h>


  void main()     
  {
      unsigned char x[9] ;
      char a[] ="12345678";
      unsigned char key;
      unsigned char d;

     while (TRUE)
     {
                        if(d=='Z')
                             {
                                while (key!=32) // push SPACE BAR to stop
                                   {
                                      get_string(x,9);
                                                           
                                       if (strcmp(x,a)==0)
                                          {                                           
                                              output_high(PIN_D0);
                                              output_high(PIN_D1);
                                              output_high(PIN_D2);
                                              output_high(PIN_D3);
                                              output_high(PIN_D4);
                                              output_high(PIN_D5);
                                              output_high(PIN_D6);
                                              output_high(PIN_D7);
                                                                                                                                                         
                                          }                                                                 
                                   } key=0;     
                             }
  }
}


Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Fri Jan 22, 2016 4:07 am     Reply with quote

How much of your while loop routine ever executes?
How do you know what the pin states are?

Have you tried setting all the portD pins to zero before the while loop?
Have you tested that all the portD pins can move?

Mike
art



Joined: 21 May 2015
Posts: 181

View user's profile Send private message

PostPosted: Fri Jan 22, 2016 4:28 am     Reply with quote

Hi mike,
If i change all output D to output B the problem will not happen. It will only happen at output D.
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Fri Jan 22, 2016 6:04 am     Reply with quote

Can you make portD work correctly by a different method?

Mike
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Jan 22, 2016 6:25 am     Reply with quote

First thought was another peripheral is active on those pins but it is Odd that a nibble is not working. Perhaps it's a wiring problem. As the code 'worked on port B', I suspect hardware..maybe no power to those 4 LEDs?
Would need to see schematic and/or photo to help more.

A simple 1Hz LED program for all pins, as Mike says, might be useful.


Jay
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