|
|
View previous topic :: View next topic |
Author |
Message |
Fabricio
Joined: 08 Apr 2005 Posts: 8
|
12f683 problem |
Posted: Thu May 26, 2005 3:22 pm |
|
|
Hi, i am using the pic 12f683, ccs 3.190 and winpic800. I can read, verify and erase the microcontroller, but when i try to programme it gives me an error in direc 0x0000.
My code is:
#include <12F683.h>
#use delay(clock=8000000)
#fuses NOWDT,INTRC_IO, NOCPD, NOPROTECT, MCLR, NOPUT, NOBROWNOUT, IESO, NOFCMEN
#use rs232(baud=9600,parity=N,xmit=PIN_A0,rcv=PIN_A1,bits=8)
#byte OSCCON = 0x8F
long rise;
#int_RA
RA3_isr()
{
rise = get_timer1();
set_timer1(0);
}
void main()
{
set_tris_a(0b001010);
OSCCON = 0x71; // Setup for 8 MHz with internal oscillator (*)
//setup_oscillator(OSC_8MHZ); // select 8MHz internal clock(*)
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
setup_comparator(NC_NC_NC_NC);
enable_interrupts(INT_RA3);
enable_interrupts(GLOBAL);
while (1)
{
delay_ms(2000);
printf("%lu\n\r",rise);
rise=0;
}
}
(*) I have proved both options.
Any idea??
thanks. greetings |
|
|
Fabricio
Joined: 08 Apr 2005 Posts: 8
|
|
Posted: Mon May 30, 2005 8:18 am |
|
|
problem solved, it was an error of configuration of the winpic
my problem now is that I set:
#use rs232 (baud=9600, parity=N, xmit=PIN_A0, rcv=PIN_A1, bits=8, restart_wdt)
but in the hyperterminal, the correct configuration is
4800.
Is it a problem of the clock?? |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Mon May 30, 2005 8:38 am |
|
|
Quote: | #use rs232 (baud=9600, parity=N, xmit=PIN_A0, rcv=PIN_A1, bits=8, restart_wdt)
but in the hyperterminal, the correct configuration is
4800.
Is it a problem of the clock?? | I guess your clock is running at 4MHz and not at 8MHz. You still have OSCCON = 0x71 in your code? This should be the correct value for an 8MHz clock.
Or there is a bug in the CCS compiler (this is a relative new chip).... |
|
|
Fabricio
Joined: 08 Apr 2005 Posts: 8
|
|
Posted: Wed Jun 01, 2005 10:46 am |
|
|
new problem.
I used the restart_cause() funtion and it give me: NORMAL_POWER_UP 24.
My output is:
START
Restart=24
START
Restart=24
START
Restart=24
START
Restart=24
(reset continually) but when i put an signal in GP2(CCP1 in), the interruption is executed and prints 'XXXXXXXX......
Where is my error?
my code is:
#include <12F683.h>
#device adc=8
#use delay(clock=4000000)
#fuses WDT,INTRC_IO, NOCPD, NOPROTECT, NOMCLR, NOPUT, NOBROWNOUT, NOIESO, NOFCMEN
#use rs232(baud=9600,parity=N,xmit=PIN_A0,rcv=PIN_A1,bits=8,restart_wdt,errors)
#ROM 0x7FF={0x3400}
long rise;
//--------------------------------
#int_CCP1
CCP1_isr()
{
putc('X');
}
//---------------------------------
void Constructor (void);
void main()
{
long aux;
restart_wdt();
aux=restart_cause();
printf("Restart=%lu\n\r",aux);
printf("START\n\r");
Constructor ();
while (1)
{
restart_wdt();
printf("do something\r");
delay_ms(2000);
//rise=0;
}
}
//-----------------------------------------------
void Constructor (void)
{
restart_wdt();
set_tris_a(0b001110);
#ASM
movlw 0x8f// OSCCON
movwf 0x04
movlw 0b1100101// 4M, intternal clock, stable
movwf 0x00
movlw 0x90// OSCTUNE – OSCILLATOR TUNING
movwf 0x04
movlw 0b00000//
movwf 0x00
movlw 0x81// OPTION REG
movwf 0x04
movlw 0b11001000 // pull up dis,prescaler a wdt
movwf 0x00
movlw 0x8C// PIE1 periph interrup enable
movwf 0x04
movlw 0b00100000 // CCP1 enable
movwf 0x00
movlw 0x15//CCP1CON CCP control reg
movwf 0x04
movlw 0b00000101
movwf 0x00
movlw 0x10//T1CON
movwf 0x04
movlw 0b00000001
movwf 0x00
movlw 0x2007 // config
movwf 0x04
movlw 0b11000011011100 //
movwf 0x00
#ENDASM
setup_adc_ports(0);
setup_adc(ADC_OFF);
//setup_counters(RTCC_INTERNAL,RTCC_DIV_1);
//setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
setup_timer_2(T2_DISABLED,0,1);
//setup_ccp1(CCP_CAPTURE_RE);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
//enable_interrupts(INT_CCP1);
enable_interrupts(GLOBAL);
} |
|
|
Fabricio
Joined: 08 Apr 2005 Posts: 8
|
|
Posted: Wed Jun 01, 2005 11:18 am |
|
|
sorry, i forget to kick on the wdt when I use delay_ms, now it is working correctly. the correct instruction is:
#use delay (clock=4000000, restart_wdt) |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jun 01, 2005 11:22 am |
|
|
Do you believe that this code works ?
Quote: | movlw 0x2007 // config
movwf 0x04
movlw 0b11000011011100 //
movwf 0x00 |
What is the size of the W register ?
What does the 12F683 data sheet say (in Section 12.1) about ROM address 0x2007 ? |
|
|
Fabricio
Joined: 08 Apr 2005 Posts: 8
|
|
Posted: Wed Jun 01, 2005 1:16 pm |
|
|
the compiler does not generate error, nevertheless, now I am not using this piece of code.
The data sheet recommends to read “PIC12F6XX/16F6XX Memory Program-ming Specification” (DS41204). I have not read this yet.
For what I understand, only it is possible to have access to this direction during the programming. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jun 01, 2005 1:21 pm |
|
|
The data sheet says this:
Quote: | Note: Address 2007h is beyond the user
program memory space. It belongs to the
special configuration memory space
(2000h-3FFFh), which can be accessed
only during programming. See
�PIC12F6XX/16F6XX Memory Program-ming
Specification� (DS41204) for more
information. |
|
|
|
|
|
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
|