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

18f46k22 RS232 not work in real test (SOLVED)

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
asadi.siyavash@gmail.com



Joined: 22 Aug 2013
Posts: 22

View user's profile Send private message Send e-mail

18f46k22 RS232 not work in real test (SOLVED)
PostPosted: Sat Aug 24, 2013 6:49 am     Reply with quote

Hi all,
I have a problem with 18f46k22, I simulate it in Proteus it work very well but when I want to do it in real it doesn't work just I see 00 in output of rs232 this is my code:
Code:

#include <18F46K22.h>
#device adc=16

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
//#FUSES INTRC_IO                 //Internal RC Osc, no CLKOUT
#FUSES NOPLLEN                  //4X HW PLL disabled, 4X PLL enabled in software
#FUSES NOBROWNOUT               //No brownout reset
#FUSES WDT_NOSLEEP              //Watch Dog Timer, disabled during SLEEP
#FUSES NOPBADEN                 //PORTB pins are configured as digital I/O on RESET
#FUSES NOMCLR                   //Master Clear pin used for I/O
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOXINST
#use delay(clock=20000000)                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode) 
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
//!#byte SPBRG =0xFAF
//!#byte SPBRGH=0xFB0
//!#byte TXSTA =0xFAC
//!#byte BAUDCON=0xFB8
//!#BIT  BRG16 =0xFB8.3
//!
void main()
{
   port_B_pullups(0xFF);
   setup_timer_3(T3_DISABLED | T3_DIV_BY_1);
   setup_timer_4(T4_DISABLED,0,1);
   setup_timer_5(T5_DISABLED | T5_DIV_BY_1);
   setup_timer_6(T6_DISABLED,0,1);

   setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
output_b(0xFF);
   while(TRUE)
   {
printf("hi");
delay_ms(1000);

   }

}

I think i should set some registers, but I don't know anything about it and I don't use it before, I'll be glad to help me,
best regards.


Last edited by asadi.siyavash@gmail.com on Sat Aug 24, 2013 7:11 am; edited 1 time in total
asadi.siyavash@gmail.com



Joined: 22 Aug 2013
Posts: 22

View user's profile Send private message Send e-mail

PostPosted: Sat Aug 24, 2013 7:11 am     Reply with quote

I solve it,
my problem was in set fuses
correct fuse set is :
Code:

#fuses HSH,PUT,NOPROTECT,NOLVP,NOWDT,NOBROWNOUT,NOPLLEN,NOPBADEN

I don't delete this topic because maybe someone like me will have same problem.
temtronic



Joined: 01 Jul 2010
Posts: 9225
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Aug 24, 2013 11:26 am     Reply with quote

Now you know WHY regulars here do NOT use Proteus !!

It cannot properly simulate even very,very simple code.

Do yourself a big favour, delete and NEVER reinstall it.

jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Sat Aug 24, 2013 12:15 pm     Reply with quote

Can I say, why do people refer to Proteus, when they mean Isis.... Smile

Proteus, is a very good schematic PCB package. I use it. It has an attached simulator (Isis), which is also competent for analog simulation. It also links to a PCB drafting package (Ares).

The first problem with Isis, is that PIC's are just too varied for it. For example the rules that work for the I2C on one PIC will be wrong for another, but the supplied rules don't cope with this. Biggest problem though is that it takes what you tell it as gospel. If you say "I'm using a 10MHz clock", it'll accept this, even if the selected oscillator fuses haven't got a hope of working. It also has more complex problems when you use a lot of peripherals. Often telling you things won't work, when they are from working chips, or that they will, when the decoupling is incompetent....

It will work for basic PIC configurations, if setup correctly, but these are the ones that any experienced PIC user would know without trying. Unfortunately for anything more complex, it is likely to mislead you. It is too easy to generate configurations that won't work in the real world, but run in the simulation.

I have Proteus, Ares, and Isis. I use Proteus and Ares to draw PCB's. I will sometimes use Isis rather than Spice for analog. However Isis and the PIC, I consider 'useless'.

Unfortunately a large number of educators seem 'unaware' of it's limitations, and encourage students to use it.

Best Wishes
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