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

12F675 gp0 led blinks - Not run -Please, they help

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



Joined: 29 Sep 2003
Posts: 4

View user's profile Send private message

12F675 gp0 led blinks - Not run -Please, they help
PostPosted: Sun Oct 05, 2003 8:23 am     Reply with quote

hello,
I am trying to make my first program with the 12f675, but it does not function. I am using the copilador pcm 3.178, hardware: pin_1 = +5V,
pin_8 = gnd, pin_7 to the K led, the Anode Led on to an electrical resistance of 390R on to Vcc(5V).
Already I made the program in ASM and functions. therefore my pic is good.
Please, they help Confused .

grateful,

Gutierres.

code is:

#include <12f675.h>
#fuses INTRC_IO,PUT,NOWDT,NOPROTECT,NOMCLR, BROWNOUT
#use delay(clock=4000000)

#use fast_io(a)

#byte ADCON0 = 0x1F
#byte ANSEL = 0x9F
#byte CMCON = 0x19

#rom 0x3ff = {0x3470} // input the calibration code

main()
{

ADCON0 = 0; // ADC off
ANSEL = 0; // GPIO pins 0,1,2 and 4 set to all digital
CMCON = 7; // Comparators off

//setup i/o
set_tris_a(0b111110); //GP0 output

while(true)
{
delay_ms(100);
output_high(pin_a0); //GP0 high
delay_ms(100);
output_low(pin_a0); //GP0 low
}
}
Felix Althaus



Joined: 09 Sep 2003
Posts: 67
Location: Winterthur, Switzerland

View user's profile Send private message

PostPosted: Sun Oct 05, 2003 9:35 am     Reply with quote

Hi

I'm working with the 12F675 for the first time too...

Perhaps the problem is in the following line:
//setup i/o
set_tris_a(0b111110); //GP0 output

You only use 6 bits in your binary number nut TRISIO is a 8Bit register. I don't know how (from left or from right) the compiler fills the other two bits, so perhaps the TRIS bits of GP0 and GP1 are 1 -> input

I would write:

set_tris_a(0b11111110); // only GP0 = output

may this helps
mfg
Felix
adilson_gutierres



Joined: 29 Sep 2003
Posts: 4

View user's profile Send private message

PostPosted: Sun Oct 05, 2003 10:41 am     Reply with quote

Hi Felix,
is not this the problem. you a binary minor can use.
I made the alteration, but also it did not function.
I continue with the problem
...

Felix Althaus wrote:
Hi

I'm working with the 12F675 for the first time too...

Perhaps the problem is in the following line:
//setup i/o
set_tris_a(0b111110); //GP0 output

You only use 6 bits in your binary number nut TRISIO is a 8Bit register. I don't know how (from left or from right) the compiler fills the other two bits, so perhaps the TRIS bits of GP0 and GP1 are 1 -> input

I would write:

set_tris_a(0b11111110); // only GP0 = output

may this helps
mfg
Felix
Ttelmah
Guest







Re: 12F675 gp0 led blinks - Not run -Please, they help
PostPosted: Sun Oct 05, 2003 12:18 pm     Reply with quote

adilson_gutierres wrote:
hello,
I am trying to make my first program with the 12f675, but it does not function. I am using the copilador pcm 3.178, hardware: pin_1 = +5V,
pin_8 = gnd, pin_7 to the K led, the Anode Led on to an electrical resistance of 390R on to Vcc(5V).
Already I made the program in ASM and functions. therefore my pic is good.
Please, they help Confused .

grateful,

Gutierres.

code is:

#include <12f675.h>
#fuses INTRC_IO,PUT,NOWDT,NOPROTECT,NOMCLR, BROWNOUT
#use delay(clock=4000000)

#use fast_io(a)

#byte ADCON0 = 0x1F
#byte ANSEL = 0x9F
#byte CMCON = 0x19

#rom 0x3ff = {0x3470} // input the calibration code

main()
{

ADCON0 = 0; // ADC off
ANSEL = 0; // GPIO pins 0,1,2 and 4 set to all digital
CMCON = 7; // Comparators off

//setup i/o
set_tris_a(0b111110); //GP0 output

while(true)
{
delay_ms(100);
output_high(pin_a0); //GP0 high
delay_ms(100);
output_low(pin_a0); //GP0 low
}
}

Try using the internal functions instead, to clear the comparators, and ADC. So:

#include <12f675.h>
#fuses INTRC_IO,PUT,NOWDT,NOPROTECT,NOMCLR, BROWNOUT
#use delay(clock=4000000)

#use fast_io(a)

#rom 0x3ff = {0x3470} // input the calibration code

main()
{

setup_adc(NO_ANALOGS);
setup_comparator(NC_NC_NC_NC); // Comparators off

//setup i/o
set_tris_a(0b111110); //GP0 output

while(true)
{
delay_ms(100);
output_high(pin_a0); //GP0 high
delay_ms(100);
output_low(pin_a0); //GP0 low
}
}


The interesting thing is, that the compiler inserts a delay after doing the comparator change, together with a 'dummy' read of the TRIS register, when it's own function is used. Why it does this, I cannot see, but if it makes the code work, there may be a 'reason' for this. They also clear the comparator interrupt flag as well.
Also they do the I/O to the analog register with the operation the other way round (change selection, then disable the AD). I remember in the past, on another PIC, having problems if this sequence was not followed.
So, try their functions, and if it starts working, then look at the assembler, and see if you can identify what difference makes it work.

Best Wishes
adilson_gutierres



Joined: 29 Sep 2003
Posts: 4

View user's profile Send private message

Re: 12F675 gp0 led blinks - Not run -Please, they help
PostPosted: Sun Oct 05, 2003 5:28 pm     Reply with quote

I discovered that using external crystal it functions ( _XT_OSC)
I made a reading from memory with my programmer, and noticed that the address 3ff is blank.
my programmer alone records until the address 3fe( PICSTART PLUS ver 3.11.0).
I do not know more what to make.
Felix Althaus



Joined: 09 Sep 2003
Posts: 67
Location: Winterthur, Switzerland

View user's profile Send private message

PostPosted: Mon Oct 06, 2003 3:20 am     Reply with quote

Which programmer do you use?

If PicStart+ with MPLAB, perhaps there is a setting option (in 6.2 there is one) where you can select which regions the programmer programs. Perhaps the option "calibration data" is deactivated (?)

mfg
Felix
adilson_gutierres



Joined: 29 Sep 2003
Posts: 4

View user's profile Send private message

PostPosted: Mon Oct 06, 2003 5:35 am     Reply with quote

Tks Felix,
I am using picstart+ and MPLA¨B6.30.
I disactivated "calibration memory", but also I did not have success. This is very strange.
To function I had that to substitute in .hex the lines of "call 0x3ff" and "movwf 0x10" for "NOP". In this case the 12f675 uses calibration 0x80 that he is default.
If to leave without the changes when to execute "call 0x3ff" it does not go to find "retlw xx" provoking one reset and a perpetual Loop of error
I do not have more what to make to solve this case.
If somebody to know, helps me.
Felix Althaus



Joined: 09 Sep 2003
Posts: 67
Location: Winterthur, Switzerland

View user's profile Send private message

PostPosted: Mon Oct 06, 2003 10:59 am     Reply with quote

Hi

The "calibration memory" should be ACTIVATED!!
What happens, if you let blink another pin (or the whole port)?

mfg
Felix
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