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

PIC16F630 PortA as outputs - is there some trick to this?

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



Joined: 16 Sep 2003
Posts: 21

View user's profile Send private message

PIC16F630 PortA as outputs - is there some trick to this?
PostPosted: Thu Jun 03, 2004 2:29 pm     Reply with quote

Sorry if I ended up double posting this.. but it did not seem to show up

I just got an F630 up and running - just testing with blinking LED's on Port A & C to see if int osc works. However, I can't get portA to work.
C4 blinks but A4 does not. Looking at the Microchip data sheet PortA info to see if I missed something setting up the port as the assembly looks ok.



#include <16F630.h>
#fuses INTRC,NOWDT,MCLR
#use delay(clock=4000000)


void main() {
set_tris_a (0x00);
while(True){

delay_ms(1000);
output_high(PIN_C4);
output_high(PIN_A4);

delay_ms(1000);
output_low(PIN_C4);
output_low(PIN_A4);
}


}
while(True){
.................... delay_ms(1000);
0027: MOVLW 04
0028: BCF 03.5
0029: MOVWF 21
002A: MOVLW FA
002B: MOVWF 22
002C: CALL 00A
002D: DECFSZ 21,F
002E: GOTO 02A
.................... output_high(PIN_C4);
002F: BSF 03.5
0030: BCF 07.4
0031: BCF 03.5
0032: BSF 07.4
.................... output_high(PIN_A4);
0033: BSF 03.5
0034: BCF 05.4
0035: BCF 03.5
0036: BSF 05.4
.................... delay_ms(1000);
0037: MOVLW 04
0038: MOVWF 21
0039: MOVLW FA
003A: MOVWF 22
003B: CALL 00A
003C: DECFSZ 21,F
003D: GOTO 039
.................... output_low(PIN_C4);
003E: BSF 03.5
003F: BCF 07.4
0040: BCF 03.5
0041: BCF 07.4
.................... output_low(PIN_A4);
0042: BSF 03.5
0043: BCF 05.4
0044: BCF 03.5
0045: BCF 05.4
.................... }
0046: BSF 03.5
0047: GOTO 027
Ttelmah
Guest







Re: PIC16F630 PortA as outputs - is there some trick to thi
PostPosted: Thu Jun 03, 2004 2:43 pm     Reply with quote

eric wrote:
Sorry if I ended up double posting this.. but it did not seem to show up

I just got an F630 up and running - just testing with blinking LED's on Port A & C to see if int osc works. However, I can't get portA to work.
C4 blinks but A4 does not. Looking at the Microchip data sheet PortA info to see if I missed something setting up the port as the assembly looks ok.



#include <16F630.h>
#fuses INTRC,NOWDT,MCLR
#use delay(clock=4000000)


void main() {
set_tris_a (0x00);
while(True){

delay_ms(1000);
output_high(PIN_C4);
output_high(PIN_A4);

delay_ms(1000);
output_low(PIN_C4);
output_low(PIN_A4);
}


}
while(True){
.................... delay_ms(1000);
0027: MOVLW 04
0028: BCF 03.5
0029: MOVWF 21
002A: MOVLW FA
002B: MOVWF 22
002C: CALL 00A
002D: DECFSZ 21,F
002E: GOTO 02A
.................... output_high(PIN_C4);
002F: BSF 03.5
0030: BCF 07.4
0031: BCF 03.5
0032: BSF 07.4
.................... output_high(PIN_A4);
0033: BSF 03.5
0034: BCF 05.4
0035: BCF 03.5
0036: BSF 05.4
.................... delay_ms(1000);
0037: MOVLW 04
0038: MOVWF 21
0039: MOVLW FA
003A: MOVWF 22
003B: CALL 00A
003C: DECFSZ 21,F
003D: GOTO 039
.................... output_low(PIN_C4);
003E: BSF 03.5
003F: BCF 07.4
0040: BCF 03.5
0041: BCF 07.4
.................... output_low(PIN_A4);
0042: BSF 03.5
0043: BCF 05.4
0044: BCF 03.5
0045: BCF 05.4
.................... }
0046: BSF 03.5
0047: GOTO 027


Turn off the AD functions on this pin. try:
SETUP_ADC_PORTS(NO_ANALOG);
during the initialisation part of the code.

Best Wishes
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jun 03, 2004 2:51 pm     Reply with quote

Quote:
I just got an F630 up and running. However, I can't get portA to work.

Whenever Port A doesn't work on one of the newer PIC chips
(ie., anything newer than the 16F877), always look in the
data sheet to see if comparators are present on Port A.
If they are, then put in a line of code to turn them off.
This will let you use Port A for digital i/o.

Code:
main()
{
setup_comparator(NC_NC_NC_NC);   // Disable comparators

// Put your other code here.

while(1);   // Prevent PIC from going to sleep
}
eric



Joined: 16 Sep 2003
Posts: 21

View user's profile Send private message

PostPosted: Thu Jun 03, 2004 5:49 pm     Reply with quote

I tired both of them but no luck - I was looking for a little luck since this chip does not have a working debug mode.... so more work to read all the port A registers.

I disabled Timer1 as well jsut in case.

The output of this pin is 2.5 v. I'll have to check whether I'm getting clockout on this pin instead.
pin options below

RA4 TTL CMOS Bi-directional I/O w/ programmable pull-up and
Interrupt-on-change
T1G ST � Timer1 gate
AN3 AN3 � A/D Channel 3 input
OSC2 � XTAL Crystal/Resonator
CLKOUT � CMOS FOSC/4 output
eric



Joined: 16 Sep 2003
Posts: 21

View user's profile Send private message

OK thanks for the help - had no IDEA
PostPosted: Thu Jun 03, 2004 6:07 pm     Reply with quote

that INTRC would gerneate a clock
I would have thought that that INTRC_IO would have if anything.

With INTRC I was, of course, getting the Fosc/4 on A4

Seems like I will have to manually "debug" all these function overloaded pins.
Rolling Eyes

Probably did not help that my scope probe pulled the LED resistor out - it was quite a few minutes before I realized I fixed it Smile
lucky



Joined: 12 Sep 2003
Posts: 46
Location: South Coast - England

View user's profile Send private message Visit poster's website

PIN A4
PostPosted: Mon Jun 07, 2004 3:35 am     Reply with quote

Hello Eric,

Pin A4 is open drain on some (maybe all) PICs. I am not sure about the 16F630 but if it is then you will need a pull-up resistor.
_________________
Lucky
www.mpic3.com - MPIC3 player project, Forum, Downloads, Online Shop
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