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

how to send address and Hexadecimal value use UART

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



Joined: 13 Apr 2018
Posts: 3
Location: Malaysia

View user's profile Send private message

how to send address and Hexadecimal value use UART
PostPosted: Fri Apr 13, 2018 6:59 pm     Reply with quote

how to convert this code from hi-Tech C to CCS C Compiler:
i use MP14A (multiPWM) connected to PIC16F877A.


This Coding from Hi-Tech to activate the MultiPWM use UART:

send_serial(0x01); // send channel of PWM to activate PWM1
send_serial(0x7f); //send PWM value.PWM value for PWM1 is 127
send_serial(0x02); // send channel of PWM to activate PWM2
send_serial(0xff); //send PWM value.PWM value for PWM1 is 255

When i code in CCS C compiler like this it not working at all:

printf("%X",0x01); // Channel PWM1
printf("%X",0xFF); //Value of PWM
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Apr 13, 2018 7:40 pm     Reply with quote

Use putc(). It should work. Example:
Code:

putc(0x01); // send channel of PWM to activate PWM1
putc(0x7F); // send PWM value.PWM value for PWM1 is 127
putc(0x02); // send channel of PWM to activate PWM2
putc(0xFF); // send PWM value.PWM value for PWM1 is 255


Also, you don't have to use hex. You can just use the numbers. Example:
Code:

putc(1);   // Ch. 1
putc(127); // PWM value

putc(2);   // Ch. 2
putc(255); // PMW value

Here is the user's manual for the Cytron MP14A Multi-PWM chip (14-channels):
http://synacorp.my/v2/en/index.php?controller=attachment&id_attachment=267
Ttelmah



Joined: 11 Mar 2010
Posts: 19496

View user's profile Send private message

PostPosted: Fri Apr 13, 2018 11:36 pm     Reply with quote

It's perhaps worth explaining 'why'.

Putc sends the single character. putc(0x1); sends the binary character '1' on the serial.
printf("%X",0x01); // Channel PWM1
This sends the value 1, encoded as an ASCII character. So the binary value 0x31.
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