how to send address and Hexadecimal value use UART
Posted: Fri Apr 13, 2018 6:59 pm
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
Posted: Fri Apr 13, 2018 7:40 pm
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:
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.
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