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

Write a 16 bit register
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Mar 01, 2012 1:37 am     Reply with quote

Quote:
I assume when I do set_uart_speed, the compiler generates code that stops the uart and puts the new value

It doesn't. The EUSART module basically allows to change the baud rate during operation. Of course, ongoing transmission or reception will be affected.

The restriction of set_uart_speed() to constant baud rate parameters has a rather trivial reason, the operation requires to put in the current clock speed according to the #delay statement in effect. It's simply a concession to user convenience. In addition, the function sets the related BRGH and BRG16 bits, which could be saved when just changing the value.

You most likely noticed, that set_uart_speed() is setting LSB first, while the CCS built-in 16-Bit access uses MSB first. The latter order is required for some 16-Bit registers like timers. According to the datasheet, it seems to be irrelevant for BRG accesses.

The CCS manual suggests to set alternative baudrates in a case structure. Obviously the solution doesn't serve all possible requirements.
Ttelmah



Joined: 11 Mar 2010
Posts: 20161

View user's profile Send private message

PostPosted: Thu Mar 01, 2012 9:53 am     Reply with quote

I think there is one other thing beyond the basic simplicity of restricting to a constant, which is that it allows the compiler to check for sensible rates. To actually code a universal function, you'd have to work out the switch points for different dividers, and once you have then calculated the divider and BRG value, then check the error percentage. A lot of work, and the function would then have to return an error flag to say that the requested rate is not achievable....

Best Wishes
maria100



Joined: 01 Feb 2012
Posts: 63

View user's profile Send private message

PostPosted: Thu Mar 01, 2012 3:51 pm     Reply with quote

i done it...the main problem remains how quick the flash is gonna be killed....to many writes per second to the registers...
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Mar 01, 2012 5:12 pm     Reply with quote

You didn't yet mention anything like writing to flash, I dodn't see how it's related to the original problem.
temtronic



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

View user's profile Send private message

PostPosted: Thu Mar 01, 2012 5:42 pm     Reply with quote

and...now its about baudrate, which, if the yet unknown PIC has autobaud detection, can 'lock onto' the other device. If your PIC doesn't have that feature, uChip has information about writing your own 'autobaud' code.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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