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

I/O Problem

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



Joined: 10 Oct 2005
Posts: 4

View user's profile Send private message

I/O Problem
PostPosted: Thu Feb 09, 2006 9:23 am     Reply with quote

Hello,

I'm trying to use PIC16F946, when I define ports as input that's ok, it works. But when I define ports as output that goes high automatically, I try to clear and change it in software but no way, output is always high! Previously I used 16f628, 16f785 etc. without problem. But i can't do it at this time. I also disable LCD module and A/D module like this:

Code:
     SETUP_ADC(ADC_OFF);
     setup_lcd(LCD_DISABLED);
     SETUP_WDT(WDT_OFF);


Can you help me?

Thank you.


I use PCWH Compiler
IDE Version 3.233
PCB Version 3.233
PCM Version 3.233
PCH Version 3.233
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Feb 09, 2006 12:22 pm     Reply with quote

You need to post a test program that shows the problem. We need
to know what ports you are using when the problem occurs.
ElectroNick



Joined: 10 Oct 2005
Posts: 4

View user's profile Send private message

test program
PostPosted: Fri Feb 10, 2006 2:02 am     Reply with quote

This is my test program, but that doesn't work:

Code:
#include "16F946.h"
#fuses NOWDT, NOMCLR, PROTECT, INTRC_IO, NOBROWNOUT, NODEBUG, NOIESO, NOFCMEN, NOPUT
#use delay (clock=4000000)

#define   ALL_OUT 0
#define ALL_IN 0xFF

void main ()
{
   
   SETUP_ADC(ADC_OFF);
   SETUP_ADC_PORTS(NO_ANALOGS);
   setup_lcd(LCD_DISABLED);
   SETUP_WDT(WDT_OFF);

   SET_TRIS_A(0b10101011);      
   SET_TRIS_B(ALL_OUT);      
   SET_TRIS_C(0b01011000);      
   SET_TRIS_D(0b11010000);      
   SET_TRIS_E(0b00011111);      
   SET_TRIS_F(0b00001111);      
   SET_TRIS_G(ALL_IN);   

   while (TRUE)
   {
      output_toggle(PIN_B0);
      output_toggle(PIN_B1);
      delay_ms(1000);
   }
}



I can't change the port values in CCS but I wrote a simple program in asm and it changes. But I can't write program in asm, it is too difficult to do it.

Is there anyone who can understand the problem?

Thank you.
Einstein
Guest







PostPosted: Tue May 30, 2006 6:21 am     Reply with quote

I have the same problem with Ports F and G.

After controlling the generated ASM code from the compiler,
I noticed that the TRIS Register definition of Port F and G was
understood wrong from the compiler. He locates these ports into
register 0xA and 0xB, that is used by PCLATH and INTCON.

I tested it, written the TRIS definition in asm and it works.

I am still trying to understand where to change the memory location/definiton for this device in the compiler.

regards,
AE
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue May 30, 2006 12:04 pm     Reply with quote

You can write directly to the TRISF and TRISG registers in the 16F946
by using the following method:
Code:

#byte TRISF = 0x185
#byte TRISG = 0x187

void main()
{
TRISF = 0xFF;   // All inputs
TRISG = 0x00;  // All outputs


while(1);
}
Einstein
Guest







PostPosted: Wed May 31, 2006 5:57 am     Reply with quote

I updated by compiler version to 3.249 and the problem was resolved.

THX,

AE
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