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 support@ccsinfo.com

send a string with RS232

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







send a string with RS232
PostPosted: Tue May 12, 2009 5:10 pm     Reply with quote

Hello,
I want to send a string from my PC to my PIC16F877. I have just send one character and it works perfectly but I haven't any idea how to send a string composed of three characters.
Please if any one has an idea help me and thank you so much.
f
Guest







PostPosted: Wed May 13, 2009 3:09 am     Reply with quote

I tried this code and it is not working. Please advise me how to do Crying or Very sad
Code:
#include <16F877.h>
#include <string.h>
#use delay(clock=4000000)
#fuses hs, noprotect, nowdt,nolvp
#include <stdlib.h>
#include <stdio.h>
#use rs232(baud=19200, xmit=PIN_C6, rcv=PIN_C7)
#define STRING_SIZE 40
#define BUFFER_SIZE 32

BYTE buffer[BUFFER_SIZE];
BYTE next_in = 0;

#int_rda
void serial_received()
{
   int t;
   do{
   buffer[next_in]=getc();
   t=next_in;
   next_in=(next_in+1) % BUFFER_SIZE;
   }while(next_in<=3);
}

void main()
{
int duty;

output_low(PIN_B1);

enable_interrupts(INT_RDA); //interrupt fires when the receive data is available, RS232 ON
enable_interrupts(GLOBAL); //activation de sinterruption

setup_timer_2(T2_DIV_BY_1,255, 1); //génération du PWM
setup_ccp1(CCP_PWM);

main_program:
do
{

duty=atoi(buffer);
set_pwm1_duty(duty);

}while(TRUE);

goto main_program;

}

Please if any one see my mistake???!! Question
bungee-



Joined: 27 Jun 2007
Posts: 206

View user's profile Send private message

PostPosted: Wed May 13, 2009 4:09 am     Reply with quote

Instead of sending your string to PWM directly try to echo back to the RS232 to see what you are receiving to the PIC.
Wink
faffou



Joined: 12 May 2009
Posts: 2

View user's profile Send private message

PostPosted: Wed May 13, 2009 2:40 pm     Reply with quote

Hi, sorry , do you mean that I transmit what I receive from the PC to the PC to verify?
_________________
GOOD LUCK
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