[perverse code] speedchange during uart transmition

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi.
Not actualy doing a project that needs this buuuut...
What whold hapen if i change the value of the OSCCAL and/or CLKPR register while doing somthing with the USART/TC/AD...
Is there a good order of commands to do this?
Is somone more perverse then me and has already done this with some handy asm code?

Q: why in gods name whould you do that?
A: Because it saves power and because i can. ;)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Firstly, changing the clock rate when doing uart comms will kill any comms taking place. As for the adc - it will just take longer to do the conversion and the timers will all be slower (assuming you switch to a lower frequency). Nothing really perverse about what you're doing - why else do you think they give you a clock prescaler that can be changed on the fly?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Changing the clock for every peripheral, which rely on a certain speed (timers, UART, ADC, CAN), generate absolute rubbish.

So I think, nobody has done this or want so to do.

Peter

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Whell, my point was that I whould need to change the settings for the other HW blocks at the same time as to preserve the comunication. Ofcorse its posible to design around it so that UART and so on must be idel when doing this but i think it should be posible to do it on the fly.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Then the correct order must be the following:

1. disable UART receive
2. wait until transmit register empty
3. disable UART transmit
4. change the main clock

Peter