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

18F45K50 Fuses portb

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



Joined: 11 Oct 2017
Posts: 142

View user's profile Send private message

18F45K50 Fuses portb
PostPosted: Tue Oct 26, 2021 6:49 pm     Reply with quote

I'm trying to transfer a code from 18F4550 to 18F45K50.
The circuit uses USB HID Full Speed and works as expected, but portB is 'unstable'.
I will post the fuses to see if this is correct.
I use the internal oscillator.
Is portb properly configured to use pull up?

Fuses with '?' I don't know the meaning.

Code:
#include <18F45K50.h>
#FUSES PLLEN,NOXINST,INTRC_IO,NOFCMEN,NOIESO //1#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES PUT,NOBROWNOUT,NOWDT //2
#FUSES NOMCLR,NOLVP  //3
#FUSES NOSTVREN,NODEBUG //4
#FUSES PROTECT,CPB //5
#FUSES NOWRT,NOWRTC,NOWRTB,NOWRTD,  //?
#FUSES NOEBTR,NOEBTRB //?
#use delay(clock=48000000)
...
#use fast_io(a)
#use fast_io(b)
#use fast_io(c)
#use fast_io(d)
#use fast_io(e)
...
void main (void)
 {
   port_b_pullups(true);
   set_tris_a(0b11111111);
   set_tris_b(0b11111111);   
   set_tris_c(0b11111111);
   set_tris_d(0b01111111); //ATIVA/DESATIVA DIGITAL DOS PINOS AN
   set_tris_e(0b11111111);
...


Last edited by vtrx on Wed Oct 27, 2021 10:08 am; edited 2 times in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Oct 27, 2021 5:55 am     Reply with quote

Look in the 18F45K50 data sheet.
Quote:
11.3.1 WEAK PULL-UPS
Each of the PORTB pins has an individually controlled weak internal pull-up.

Then look in the CCS manual in the port_x_pullups( ) section.
http://www.ccsinfo.com/downloads/ccs_c_manual.pdf
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Wed Oct 27, 2021 6:16 am     Reply with quote

Also, are you totally sure whatever you are driving on port B supports
fast_io. 99% of the standard drivers require standard_io, not fast_io...
Generally, I'd only use fast_io, when dealing with a very specific device that
needs this. For 90%+ of the time standard_io is much safer.

Also, are you sure the 'weak pullups' are going to be adequate for what
is needed?. The old chip did not have these. You therefore were presumably
using external pullups. Now key word with the internal pullups, is _weak_.
They are equivalent to between about a 16.5K up to a 200K resistor
(depending on individual chips/pins). If you said possibly 50KR you would
not be far off in most cases. Now normally this is not enough for a lot
of things needing 'pullups'....
vtrx



Joined: 11 Oct 2017
Posts: 142

View user's profile Send private message

PostPosted: Wed Oct 27, 2021 8:42 am     Reply with quote

Thank you all.
Reading the manual, i realized that i have to choose which pins to enable.
With 18F4550 i used port_b_pullups(true) which works for all pins, but on 18F45K50, only RB0 is active.
I used port_b_pullups(0b11111111),so that all were enabled.
temtronic



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

View user's profile Send private message

PostPosted: Wed Oct 27, 2021 9:37 am     Reply with quote

As Mr. T says , it's best to use 'standard _IO' and let the compiler handle the 'details'.
In over 2 decades of using PICs, I've only ever need 'fast_IO', twice. Both times it was to have very,very precise timing to interface to proprietary equipment.
One problem with fast_Io , is that when you change a pin assignment, you may forget to also to change it's data direction ( input instead of output), then for some 'reason', your code that used to work, now gives 'weird' results....

As for internal pullups those are 'new' to me! I'm old and use REAL resistors, that way I KNOW the pin IS pulled up. Again, if you use internals, then you MUST remember to change your program when you change pin layouts....
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