MC9S08JM60  - RS232  baud 9600 7 Bits mode

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MC9S08JM60  - RS232  baud 9600 7 Bits mode

1,419 Views
SuperByte
Contributor I

Hi

I need help please ,  I am suing a MC9S08JM60  and current using 9600 baud with 8 bits no parity . I now

have a new device that I need to communicate with. This new device only communicates  9600, 7 bits and odd parity .

 

Could someone please help with regards to this ?

 

You help would greatly appreciated.

 

Thanks

Labels (1)
0 Kudos
10 Replies

655 Views
peg
Senior Contributor IV

Hello and welcome to the fora, SuperByte.

 

From the setup you currently have you just need to set bit 1 of SCIxC1 to enable parity and also set bit 0 to select odd parity.

Then just use it as you currently are. You will probably need to add some code to trap parity errors on the recieve side.

 

0 Kudos

655 Views
SuperByte
Contributor I

Hi Peg

 

Thank you for your prompt response .  I have already enabled theses bits  SCIxC1 = 0x3 . 

but no joy .

 

Any other suggestions

 

Thanks

 

col

0 Kudos

655 Views
bigmac
Specialist III

Hello,

 

The SPI module, when configured for 8 data bits and no parity, will generate a start bit followed by the data bits and then a stop bit.  My understanding is that, enabling parity within the SPI module will cause an additional parity bit to be inserted between the last data bit and the stop bit - not what you require.

 

The only solution that I can see is to leave the setting for 8-data bits, no parity.  You would then need to calculate the odd parity bit for each data byte, and change the MSB of the byte to suit the parity.  Then send the modified byte to the SCI.

 

Perhaps something like the following untested code would work:

 

// Returns 7 data bits + odd paritybyte odd_parity( byte val){  byte i, temp;  byte parity = 0x80;  // Initialise for odd parity  temp = val & 0x7F;  for (i = 0; i < 7; i++) {    val <<= 1;    parity ^= val;  }  return ((parity & 0x80) | temp);}

 

SCI1D = odd_parity( value);

 

For received data, you may wish to simply ignore the parity bit, so zero the MSB of the received byte.

 

Regards,

Mac

 

0 Kudos

655 Views
SuperByte
Contributor I

Hi Mac

 

Thanks for that . Could PLEASE modify the code for even parity please.

 

Thanking you in advance .

 

SuperByte

0 Kudos

655 Views
bigmac
Specialist III

Hello SuperByte,

 


SuperByte wrote:

Could PLEASE modify the code for even parity please.


byte parity = 0x00;  // Initialise for even parity

Regards,

Mac

 

 

0 Kudos

655 Views
peg
Senior Contributor IV

Hello,

I do not have any direct experience with the JM, however my experience with 8-bit plus parity on the GT leads me to believe that the way I previously described is the correct way to set up 7-bit plus parity. This is also how the manual describes it with the parity bit in the eighth position.

0 Kudos

655 Views
rocco
Senior Contributor II

As Peg, I don't have direct experience with the JM, but I do use odd-parity on the GB.

 

In order to get 8 data-bits + parity, I need to put the SCI in 9-bit mode. So it stands to reason that you need 8-bit mode to get 7 data-bits + parity.

0 Kudos

655 Views
bigmac
Specialist III

Hello,

 

I accept that my previous understanding of the SCI operation was faulty.

 

The software method of parity generation should, however, still work, be it unnecessary in this instance.

 

Regards,

Mac

 

0 Kudos

655 Views
peg
Senior Contributor IV

Hi,

 

A bit of elaboration on "no joy" might be in order here.

Can you recieve?

Do you get parity errors at the other end if you transmit?

Presumably this is an ASCII interface so some strings may still work

Either "ABDG" or "CEFI" should still be able to get through as the parity bid does not need to be set.

 

0 Kudos

655 Views
SuperByte
Contributor I

Hi

 

Thank you for your help. Sorry I didn't get back to earlier. It turns out that the device had even parity.

The transmitting is fine and just need to check the receive routines .

 

I will let you know ASAP. Thanks for your help.

 

Cheers

0 Kudos