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

pic 16f628 | picc v4.110 PCB | use of two pins RA6 and RA7

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



Joined: 17 Nov 2012
Posts: 23

View user's profile Send private message

pic 16f628 | picc v4.110 PCB | use of two pins RA6 and RA7
PostPosted: Thu Jan 24, 2013 1:46 am     Reply with quote

Hello,
I want to use the two pins RA6 and RA7 as outputs so I configured the internal oscillator, but the two pins didn't configure as outputs.

This is my code:
Code:

#include <16f628.h>

#FUSES NOWDT
#FUSES INTRC_IO
#FUSES NOMCLR
#FUSES NOLVP
#FUSES ER_IO
#use delay(clock=4000000)

#byte porta = 0xF05
#byte portb = 0xF06
#byte trisa = 0xF85
#byte trisb = 0xF86

void main(){
            //76543210
   trisa=0b00100001;                //1:in  ;  0:out
            //76543210
   trisb=0b00000000;
   portb=0;
   porta=0;
   
   while(1){
   }

}
Ttelmah



Joined: 11 Mar 2010
Posts: 19466

View user's profile Send private message

PostPosted: Thu Jan 24, 2013 2:48 am     Reply with quote

I'm surprised it runs at all. You have _two_ oscillators selected. INTRC_IO, and ER_IO. The ER_IO selection uses pin RA7, expecting an RC oscillator on here.....
Get rid of this.

Best Wishes
louwi_138



Joined: 17 Nov 2012
Posts: 23

View user's profile Send private message

PostPosted: Thu Jan 24, 2013 3:09 am     Reply with quote

Ttelmah wrote:
I'm surprised it runs at all. You have _two_ oscillators selected. INTRC_IO, and ER_IO. The ER_IO selection uses pin RA7, expecting an RC oscillator on here.....
Get rid of this.

Best Wishes


I deleted the ER_IO . and it still the same problem.
I'm doing simulation on Isis.
RF_Developer



Joined: 07 Feb 2011
Posts: 839

View user's profile Send private message

PostPosted: Thu Jan 24, 2013 4:10 am     Reply with quote

Of course they won't: with your code all IOs will remain as inputs. In CCS C by default, the compiler sets IO direction: so called standard I/O mode. You are manually setting IO direction using TRIS. This won't work unless you use fast I/O mode on the ports.

The best thing for most CCS C programs is to forget setting the IO direction and use standard IO which sets it for you. Then you can forget tris.

Read the compiler manual to find out about the compiler's different I/O modes.

Is there any pressing need to manually set IO direction in this application? Or is it habit, or possibly because you were taught to use it?

RF Developer
louwi_138



Joined: 17 Nov 2012
Posts: 23

View user's profile Send private message

PostPosted: Thu Jan 24, 2013 4:39 am     Reply with quote

RF_Developer wrote:
Of course they won't: with your code all IOs will remain as inputs. In CCS C by default, the compiler sets IO direction: so called standard I/O mode. You are manually setting IO direction using TRIS. This won't work unless you use fast I/O mode on the ports.

The best thing for most CCS C programs is to forget setting the IO direction and use standard IO which sets it for you. Then you can forget tris.

Read the compiler manual to find out about the compiler's different I/O modes.

Is there any pressing need to manually set IO direction in this application? Or is it habit, or possibly because you were taught to use it?

RF Developer


I'm taught to use it. and I still don't know what should I do to run it ?
RF_Developer



Joined: 07 Feb 2011
Posts: 839

View user's profile Send private message

PostPosted: Thu Jan 24, 2013 5:25 am     Reply with quote

louwi_138 wrote:
I'm taught to use it. and I still don't know what should I do to run it ?


Read the CCS manual. Look up I/O modes. In other words do your own research. Then get your teacher/lecturer/whatever to do the same!

RF Developer
temtronic



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

View user's profile Send private message

PostPosted: Thu Jan 24, 2013 6:33 am     Reply with quote

Of course it won't work...

arrgh ISIS ( aka Proteus ) is in 2nd post,last line.

This 'simulator' is very well known for lots of BUGS, faulty DRCs, and other errors.

I do know that a real 16F628 runs fine on the internal oscillator doing al sorts of interesting 'things'.
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Thu Jan 24, 2013 6:35 am     Reply with quote

Sigh....

Quote:
'm doing simulation on Isis.


Read this:
http://www.ccsinfo.com/forum/viewtopic.php?t=47549



G.
_________________
CCS PCM 5.078 & CCS PCH 5.093
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Thu Jan 24, 2013 6:36 am     Reply with quote

Temtronic... you beat me to it by maybe a second!
_________________
CCS PCM 5.078 & CCS PCH 5.093
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Jan 24, 2013 7:30 am     Reply with quote

One known problem is that ISIS/Proteus doesn't look at your Fuse configuration. You have to configure the properties like clock speed inside ISIS, I don't remember the procedure but I expect to right click the processor and select 'Properties'.

Now about your program:
As RF_Developer already mentioned, in CCS there is for most programs no need to set the TRIS registers yourself, the compiler will do it for you on every I/O operation. This is called standard_io mode and unless you select another mode the compiler will change your TRIS settings. Do more reading in the CCS manual for the '#USE STANDARD_IO' command.

Then the other ugly thing is the hard coding of addresses. For many other compilers this is the only way to program the PIC but it has the disadvantage that you have to define these addresses (more typing) and when you go to another chip you have to change these values again.

In CCS your whole program can be as short as this:
Code:
#include <16f628.h>

#FUSES NOWDT
#FUSES INTRC_IO
#FUSES NOMCLR
#FUSES NOLVP
#use delay(clock=4MHz)

void main() {
   output_a(0);
   output_b(0);
   
   while(1) {
      output_toggle(PIN_A6);
      delay_ms(500);
   }
}
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