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

16F877 to 18F6622

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



Joined: 04 Mar 2009
Posts: 19

View user's profile Send private message

16F877 to 18F6622
PostPosted: Tue Mar 16, 2010 4:18 pm     Reply with quote

Hi there,

I have tested my code on the 16F877 and it works brilliantly. I have had
to change to the 18F6622 as I need two hardware usarts now.

So when I connected up the 18f6622, I started to test the two usart, but I
came across a problem:

This is the test code I'm using: (switch between usart by using pc1 or pc2)
Code:

#include <18F6622.h>
#fuses HS,NOWDT,PUT,BROWNOUT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=pc1,ERRORS)
//#use rs232(baud=9600,xmit=PIN_G1,rcv=PIN_G2,bits=8,stream=pc2,ERRORS)
void main(void)
{   
   while(1)
   {   
      fprintf(pc,"Testing123");
   }} 

1. I started by testing usart 1 which is pins c6 & c7. The first time I get
continuous 'Testing123' in the serial port monitor in PCWH, which is correct.

2. Then I switch to usart 2 which is pin g1 & g2. Then I don't get
'Testing123', but get 00 00 00 00 00 00 00 in the HEX window.
It does show that I am receiving bit as the RXD light is flashing in the
serial port monitor in PCWH.

3. So I switch back to usart 1 and the same thing happens 00 00 00 00 00 00.

I tried the code with only one #use rs232 and no stream and change
fprintf to printf, but still the same problem.

I don't understand. What is going on?
Has anyone had this problem before?

Any help is appreciated...
Thanks
piire!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Mar 16, 2010 4:25 pm     Reply with quote

What is your compiler version ?

Are you testing this in hardware, or Proteus ?
piire



Joined: 04 Mar 2009
Posts: 19

View user's profile Send private message

PostPosted: Tue Mar 16, 2010 4:29 pm     Reply with quote

I'm using 4.104 and its on hardware.
thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Mar 16, 2010 5:39 pm     Reply with quote

Quote:
3. So I switch back to usart 1 and the same thing happens 00 00 00 00 00 00.

Turn the power off, and then on again. Check all your connections.
piire



Joined: 04 Mar 2009
Posts: 19

View user's profile Send private message

PostPosted: Thu Mar 18, 2010 9:14 am     Reply with quote

hi there, i checked the connection and they look fine, but i think there is a problrm with something else as, i have found sometime both rs232 ports work, and sometimes it gives 00 00 00 00. so i tried a simple toggle led code, the led should blink 3 times quickly and it didnt work correctly either. the led turn on for longer than normal, but it did do it 3 times, but very slowly. is there something wrong with the fuses or oscillator?

the code i used:
Code:

#include <18F6622.h>
#fuses HS,NOWDT,PUT,BROWNOUT,NOLVP
#use delay(clock=20000000)
void main(void)
{   
     int i =0;
        while(i<3){
       output_high(PIN_C5);
       delay_ms(500);
       output_low(PIN_C5);
       delay_ms(500);
       i++;
}


thanks

piire
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