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
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.
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
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.
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.
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
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.
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