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

CODE CONVERSION FROM asm TO CCS C !

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



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

CODE CONVERSION FROM asm TO CCS C !
PostPosted: Mon May 01, 2006 3:23 pm     Reply with quote

Hi i am a new to CCS C i have bought a PICDEM Mechatronics Board its come with this lab example in ASM. Can you experts convert it to CCS C code so that i can understand it and try it out in C many thanks for your help .
Code:
   
   include <p16f917.inc>
   include LCD.inc

STARTUP code
   goto   Start

PORT1    code
Start
   bsf      STATUS,RP0      ; we'll set up the bank 1 Special Function Registers first
   bcf      TRISD,2         ; set RD2 as the motor output
   movlw   b'01110000'      ; select the 8Mhz internal oscillator
   movwf   OSCCON         
   movlw   0xFF         ; select 7.9 kHz PWM
   movwf   PR2
   bcf      STATUS,RP0

   movlw   b'00001100'      ; pwm mode
   movwf   CCP2CON
   bsf    T2CON,TMR2ON   ; turn on PWM
   call   InitLCD         ; Initialize the LCD module
   clrf   CCPR2L         ; Clear Duty Cycle
   bsf    ADCON0,ADON    ; Turn the ADC module on
LoopOuter
   bsf      ADCON0,GO_DONE
LoopInner
   btfsc   ADCON0,GO_DONE
   goto   LoopInner
   movf   ADRESH,w
   call   DisplayDecimal   ; Display the ADC value
   movf   ADRESH,w
;   movwf   CCPR2L         ; make POT1 reading the duty cycle
   call   QuietPWM
   goto   LoopOuter

   END


PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue May 02, 2006 12:51 am     Reply with quote

You ought to convert it, in order to learn how to use the compiler
and how to read the .LST file. It's an important skill.

It looks like they're doing something similar to the CCS example file,
EX_PWM.C. You can find this file in: c:\Program Files\PICC\Examples

You'll also need to specify the INTRC_IO fuse, and use the
setup_oscillator() function. See this post for an example:
http://www.ccsinfo.com/forum/viewtopic.php?t=26898

The CCS manual explains the CCS library functions.
http://www.ccsinfo.com/downloads/ccs_c_manual.pdf
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