View previous topic :: View next topic |
Author |
Message |
Goodwinchang
Joined: 15 Oct 2006 Posts: 18 Location: Taiwan
|
How to generate the C-code to ASM |
Posted: Tue Oct 24, 2006 4:49 am |
|
|
Dear all
I am a new comer for CCS. I have so many problems. I try PIC12F683 for my new practice. But I generate the basic function just to outptu a GPIO(PIN_A0) to High then low. I found the code is no work. I find a problem from the .LST file.
The c-code output_tris_a(0x38), I just set the A0~A2 for output and A3~A5 as the input. And the LST file show
.................... set_tris_a(0x38) ;
0037: MOVLW 38
0038: MOVWF 05
Register 05 should be the Port A and not TRIS.
I have some upset for the CCS. So I try to generate the basic functions I want from C-code then port it by ASM.
Please teach me how to generate the ASM from C_code.
Best Regards
Goodwin |
|
|
Goodwinchang
Joined: 15 Oct 2006 Posts: 18 Location: Taiwan
|
|
Posted: Tue Oct 24, 2006 4:53 am |
|
|
I find a problem for my problem that is CCS generate the correct code and when I open the C-code and compiler again in MPLAB using CCS compiler. And the problem I have happens.
Is MPLAB issue? or the compatibility issue for CCS and MPLAB>
Best Regards
Goodwin |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Oct 24, 2006 1:02 pm |
|
|
Post your small test program. Also post your compiler version. |
|
|
Goodwinchang
Joined: 15 Oct 2006 Posts: 18 Location: Taiwan
|
|
Posted: Wed Oct 25, 2006 7:28 am |
|
|
sync.c as following
#include "F:\Download\Working\CCS\1025200603\sync.h"
void main()
{
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC);
setup_vref(FALSE);
setup_oscillator(OSC_8MHZ);
// TODO: USER CODE!!
}
and sync.h as following
#include <12F683.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC //Internal RC Osc
#FUSES NOCPD //No EE protection
#FUSES NOPROTECT //Code not protected from reading
#FUSES MCLR //Master Clear pin enabled
#FUSES NOPUT //No Power Up Timer
#FUSES BROWNOUT //Reset when brownout detected
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES FCMEN //Fail-safe clock monitor enabled
#use delay(clock=8000000)
#use rs232(baud=9600,parity=N,xmit=PIN_A3,rcv=PIN_A2,bits=8,stream=RS232)
I just use this test code to try setting the internal OSC as 8MHz and output the 2MHz at A4.
And actaully it doesn't work.
Who can tell me what happens or what I do the wrong thing. |
|
|
Ttelmah Guest
|
|
Posted: Wed Oct 25, 2006 8:41 am |
|
|
Add one line to the end of the main:
while (TRUE) ;
Without this, the oscillator will wake up and run for just a few hundred cycles, then the code will drop off the end of the 'main', go to sleep, and the oscillator will stop. Unless you happend to catch the short burst of operation, it'll appear not to work.
Also, PCM programmer asked 'what compiler version'. This is vital data for answering this type of question.
Best Wishes |
|
|
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
|
Posted: Wed Oct 25, 2006 9:41 am |
|
|
Is the NOLVP fuse a gotcha with this part? |
|
|
Ttelmah Guest
|
|
Posted: Wed Oct 25, 2006 10:27 am |
|
|
No.
A damn good idea, but not on the 8 pin parts. They don't have this fuse.
Best Wishes |
|
|
|