Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

C++ windows baud rate for PIC16F628A?

Status
Not open for further replies.
Are you sure your default radix is decimal? I suspect it may be hexadecimal (18 Hex = 24 decimal) Try movlw .25 or movlw d'25' to force decimal.

Edit, MPASM defaults to hex and so I think this is your problem.

Mike.

Oh...
It must be that!

All this for such a stupid mistake...

Thanks!
 
The simplest bugs are the hardest to find. To stop it happening again add the line radix dec to your code.

Mike.
 
RB he does not have a scope. That is why I suggested the pk2.

My apologies.

vlad777 said:
...
Frequencies for chars (PC generated):
char 'V' 0x56 -- 3.8KHz
char '≡' 0xF0 -- 0.9KHz

That is not exactly correct, the USARTS always make a logic 0 start bit and a logic 1 stop bit (assuming you have selected the standard 8n1 settings). So always 10 bits to each "byte sent".

Note! As the bytes are sent LSB first each byte is REVERSED;
So to make the 10 bit string; 0101010101 you send ascii char 0x55 (01010101) and freq = baudrate / 2
and to make the 10 bit string 0000011111 you send ascii char 0xFO (11110000) and freq = baudrate / 5

(edit) As vlad777 pointed out I was wrong because the data is sent LSBit first! I have corrected the mistake so the above is correct (thanks vlad777).
 
Last edited:
Bit sting in my post #15 has 10 bits (included start and stop)

I send 0xF0 NOT 0x0F because of LSB first (after 0 start bit).

But yes I see something wrong now...

EDIT:

(So now I am sending a chunk of 10MB at once with WriteFile() and everything else comented out in the loop.
All initialized to same byte.)

For char 0x55 I get 4.8 KHz. (baud=freq*2) (Not 0xAA but 0x55 coz LSB first.)
For char 0xF0 I get 0.9 KHz. (baud=freq*10) (one full period frequency wise is 10 baud marks)
 
Last edited:
The simplest bugs are the hardest to find. To stop it happening again add the line radix dec to your code.

Mike.

Good spot Mike..... The answer was staring us in the face... 0x25 = 37 decimal.....:)
 
Thats what I call dexahecimal, its got me more than once.
 
Thats what I call dexahecimal, its got me more than once.

Nope, that's called life. Plus, it'll get you many, many, many more times.

Just be ready for it and then when it happens, post here so we can have a little snigger.

Mike.;)
 
Status
Not open for further replies.

Latest threads

Back
Top