|
|
View previous topic :: View next topic |
Author |
Message |
piire
Joined: 04 Mar 2009 Posts: 19
|
16F877 to 18F6622 |
Posted: Tue Mar 16, 2010 4:18 pm |
|
|
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
|
|
Posted: Tue Mar 16, 2010 4:25 pm |
|
|
What is your compiler version ?
Are you testing this in hardware, or Proteus ? |
|
|
piire
Joined: 04 Mar 2009 Posts: 19
|
|
Posted: Tue Mar 16, 2010 4:29 pm |
|
|
I'm using 4.104 and its on hardware.
thanks |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Mar 16, 2010 5:39 pm |
|
|
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
|
|
Posted: Thu Mar 18, 2010 9:14 am |
|
|
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 |
|
|
|
|
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
|