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

RS232 does not work - ideas?

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



Joined: 04 Jun 2007
Posts: 27

View user's profile Send private message

RS232 does not work - ideas?
PostPosted: Mon Jan 21, 2008 1:49 am     Reply with quote

main.h

Code:
#include <18F4525.h>
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
#FUSES INTRC_IO                 //Internal RC Osc, no CLKOUT
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOIESO                   //Internal External Switch Over mode disabled
#FUSES NOBROWNOUT               //No brownout reset
#FUSES BORV21                   //Brownout reset at 2.1V
#FUSES NOPUT                    //No Power Up Timer
#FUSES NOCPD                    //No EE protection
#FUSES NOSTVREN                 //Stack full/underflow will not cause reset
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT                    //Program memory not write protected
#FUSES NOWRTD                   //Data EEPROM not write protected
#FUSES NOEBTR                   //Memory not protected from table reads
#FUSES NOCPB                    //No Boot Block code protection
#FUSES NOEBTRB                  //Boot block not protected from table reads
#FUSES NOWRTC                   //configuration not registers write protected
#FUSES NOWRTB                   //Boot block not write protected
#FUSES FCMEN                    //Fail-safe clock monitor enabled
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES NOPBADEN                 //PORTB pins are configured as digital I/O on RESET
#FUSES LPT1OSC                  //Timer1 configured for low-power operation
#FUSES NOMCLR                   //Master Clear pin used for I/O

#use delay(clock=8000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)



main.c

Code:
#include "main.h"
//#include <bootloader.h>

void main()
{
unsigned long zahl=0;
char buchst;

   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF|ADC_TAD_MUL_0);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_SS_DISABLED);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   setup_oscillator(OSC_8MHZ|OSC_INTRC|OSC_PLL_OFF);


while (true)
{
   printf("enter char: \r\n");
   buchst=getc();
   printf("char: %c\r\n",buchst);
}
}


"enter char" is displayed but "char:" gets never displayed??(after I entered a char) - can there be anathing wrong with the code or is this a hardwarefailure?
D-Kens



Joined: 09 May 2005
Posts: 35
Location: Toulouse (France)

View user's profile Send private message MSN Messenger

PostPosted: Mon Jan 21, 2008 4:14 am     Reply with quote

How do you enter your char ? Did you check that the software you use (hyperterminal, or anything else) has the same settings as those defined in your RS232 settings, in main.h (9600 bauds, 8 bits, no parity...) : if you don't use the same "language" at both ends of the cable, your devices can't understand each others.
cyberant



Joined: 04 Jun 2007
Posts: 27

View user's profile Send private message

PostPosted: Mon Jan 21, 2008 9:43 am     Reply with quote

D-Kens wrote:
How do you enter your char ? Did you check that the software you use (hyperterminal, or anything else) has the same settings as those defined in your RS232 settings, in main.h (9600 bauds, 8 bits, no parity...) : if you don't use the same "language" at both ends of the cable, your devices can't understand each others.


Ive solved it - it was a 1way RS232 cable... Rolling Eyes
Guest








PostPosted: Sat Apr 12, 2008 11:34 pm     Reply with quote

hello everybody

i am able to receive characters but how i do receive string of characters?
how do i receive a sentence? thanks for the informations!
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