View previous topic :: View next topic |
Author |
Message |
young
Joined: 24 Jun 2004 Posts: 285
|
how to set 12f675 MCLR pin? |
Posted: Thu Jun 02, 2005 11:14 am |
|
|
I want to use the PIN_A3 as a reset pin (12f675), so that when I trigger this pin, the chip will reset and start again, How can I do it< I did not find the related command in ccs c. thank you |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
young
Joined: 24 Jun 2004 Posts: 285
|
|
Posted: Thu Jun 02, 2005 12:04 pm |
|
|
I used MCLR for the other chips, it works fine, when I used for the 12f675, my other function like external interrupt stop working, any possible reasons? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jun 02, 2005 12:28 pm |
|
|
Post a small complete program that shows the problem.
Be sure to post the #fuses statement, #use statements, etc.
Also post your version of the CCS compiler. |
|
|
young
Joined: 24 Jun 2004 Posts: 285
|
|
Posted: Thu Jun 02, 2005 12:40 pm |
|
|
thank you, here is the whole program:
Code: |
#if defined(__PCM__)
#include <12f675.h>
#fuses INTRC_IO,NOWDT,NOPROTECT,PUT,MCLR
#use delay(clock=4000000)
#use rs232(baud=9600, parity=N, xmit=PIN_A0,INVERT)
void LCDSetGeometry();
void LCDReset();
void LCDinit();
void LCDSetBackLight(int8 backlit);
void LCDSetContrast(int8 contr);
void LCDClrScr();
void LCDNewLine();
void LCDCR();
void LCDTab();
void LCDVerTab();
void LCDBackSpaces(int8 bspa);
void LCDSetTab(int8 Stab);
void LCDSetCursorPos(int8 x, int8 y);
void LCDClrLine(int8 x, int8 y);
void LCDSetCursorStyle();
void LCDOnOff(int8 onoff);
int16 count;
#INT_ext
void ext_isr()
{
count++;
}
void main()
{
setup_adc_ports (NO_ANALOGS);
setup_comparator(NC_NC_NC_NC); //setup_comparators(NC_NC_NC_NC); no "s"
LCDinit();
LCDClrScr();
LCDSetCursorPos(0,0);
puts("*Pulse counting*");
count=0;
EXT_INT_EDGE(L_TO_H);
enable_interrupts(INT_ext);
enable_interrupts(GLOBAL);
while(1)
{
if(input(PIN_A1))
count=0;
LCDSetCursorPos(1,1);
printf("Num=%lu ",count);
}
}
void LCDSetGeometry()
{
putc(15);
delay_ms(10);
putc(16);
delay_ms(10);
putc(0x80);
delay_ms(10);
putc(0xc0);
delay_ms(10);
putc(0x80);
delay_ms(10);
putc(0x80);
delay_ms(10);
}
void LCDReset()
{
putc(14);
delay_ms(1000);
}
void LCDinit()
{
// Set LCD Geometry
LCDSetGeometry();
// LCDReset
LCDReset();
}
void LCDSetBackLight(int8 backlit)
{
putc(20);
delay_ms(10);
putc(backlit);
}
void LCDSetContrast(int8 contr)
{
putc(19);
delay_ms(10);
putc(contr);
}
void LCDClrScr()
{
putc(12);
delay_ms(10);
}
void LCDNewLine()
{
putc(10);
delay_ms(10);
}
void LCDCR()
{
putc(10);
}
void LCDTab()
{
putc(9);
}
void LCDVerTab()
{
putc(11);
}
void LCDBackSpaces(int8 bspa)
{
int8 i;
for(i=1;i<bspa;i++)
putc(8);
}
void LCDSetTab(int8 Stab)
{
stab=(stab^0xFF)+1;
putc(16);
delay_ms(10);
putc(stab);
}
void LCDSetCursorPos(int8 x, int8 y)
{
putc(17);
// delay_ms(10);
putc(y);
// delay_ms(10);
putc(x);
// delay_ms(100); //888888// removed this increase speed
}
void LCDClrLine(int8 x, int8 y)
{
int8 nn;
lcdSetCursorPos(0,0);
for(nn=0;nn<<15;nn++)
putc(' ');
LCDSetCursorPos(0,0);
}
void LCDSetCursorStyle()
{
}
void LCDOnOff(int8 onoff)
{
if (onoff==0)
{
putc(21);
putc(0x08);
}
if (onoff==1)
{
putc(21);
putc(0x0c);
}
}
|
|
|
|
Guest
|
|
Posted: Thu Jun 02, 2005 1:08 pm |
|
|
PCM programmer wrote: | Post a small complete program that shows the problem.
Be sure to post the #fuses statement, #use statements, etc.
Also post your version of the CCS compiler. |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jun 02, 2005 1:11 pm |
|
|
I don't know who posted that, but yes, I was wishing that the program
was a bit smaller and that he had posted his compiler version. |
|
|
languer
Joined: 09 Jan 2004 Posts: 144 Location: USA
|
|
Posted: Thu Jun 02, 2005 2:01 pm |
|
|
You say the posted (not small) program works with NOMCLR but does not with MCLR.
What is MCLR tied to (not floating I hope)?
What is the source for the interrupt (EXT/GP2)?
Hopefully you understand where I am headed with this (Pulse into GP2 -> MCLR on GP3 -> bad things happen if not properly isolated). |
|
|
Guest
|
|
Posted: Thu Jun 02, 2005 2:20 pm |
|
|
the interrupt is GP2, the source of the interrupt is a square signal. the MCLR is not floating, it is connected with +5V. |
|
|
DragonPIC
Joined: 11 Nov 2003 Posts: 118
|
|
Posted: Thu Jun 02, 2005 2:26 pm |
|
|
#if defined(__PCM__)
#include <12f675.h>
I compile ok first time. Played around a little. Compiled again and error = "Missing #ENDIF". Probably not your problem, but an error. _________________ -Matt |
|
|
DragonPIC
Joined: 11 Nov 2003 Posts: 118
|
|
Posted: Thu Jun 02, 2005 3:00 pm |
|
|
My compiler ver 3.178 compiles ok and I can see in the cof file that MCLRE bit changed correctly with MCLR and NOMCLR. _________________ -Matt |
|
|
DragonPIC
Joined: 11 Nov 2003 Posts: 118
|
|
Posted: Thu Jun 02, 2005 3:18 pm |
|
|
try using INT_RA0, INT_RA1, ect for interrupts. I see them defined in the device library file. _________________ -Matt |
|
|
|