170 likes | 376 Views
Lab 7 – Serial RF Communication. Start date: Week #10 Due date: Week #11. Serial Communications. 2 types of serial ports on the HC12 Serial communication interface (SCI) = asynchronous Serial Peripheral Interface (SPI) = synchronous
E N D
Lab 7 – Serial RF Communication Start date: Week #10 Due date: Week #11
Serial Communications • 2 types of serial ports on the HC12 • Serial communication interface (SCI) = asynchronous • Serial Peripheral Interface (SPI) = synchronous • Know which one you want to use (RF has no clock signal pin)
SCI • Communication through port S • SCI0 = PS0 (RxD), PS1 (TxD) • SCI1 = PS2 (RxD), PS3 (TxD) • Can do parity (either even or odd) • Supports 8 or 9 data bits • SC0 is in use – communication with terminal
Registers • SC0CR1/SC1CR1 • Mode • Parity • SC0CR2/SC1CR2 • Transmit and receive enables • Interrupt enables • SC0SR1/SC1SR1 • Flags for complete and errors
Registers • SC0DRH/L / SC1DRH/L • Register to send/receive data through SCI • We will be using 8 data bits, so only low is required
Modes to use • Please set to use • 1 start, 8 data, 1 stop • No parity • 9600 baud • Warning SC0 is already in use – this is what you use to communicate with the terminal
RF module • The RF module sends and receives in 2 directions • From board to RF, from RF to board • The RxD and TxD lines are in reference to the RF, ie send and receive over RF • These will seem backwards from board • For RF modules with bent pins – just stick them upright into the board • Warning: sometimes the power light comes on when TxD or RxD is high – you still need to hook up the power or it will not work
Sending Messages • Special Characters in use • SOH – start of header • ASCII $01 • STX – start of text • ASCII $02 • ETX – end of text • ASCII $03 • EOT – end of transmission • ASCII $04
Sending Messages • Special Characters • The base station prints the characters as text because it is easier to read • When you are printing you will see them as special characters (^x)
Message Passing • Base station sends out message to a group • That group stores/prints the message and replies • The base station stores/prints the message and replies • The group stores/prints the message
Message Format – Base Station • Base Station 1st send Message • SOH • GroupXX • STX • Message • ETX • EOT
Message Format - groupXX • Group Reply • STX • Some message less than 20 chars • ETX • EOT
Message Format – Base Station • Base Station Reply to group • SOH • GroupXX • STX • Some other message • ETX • EOT
General Notes / Hints • Please put a short delay between when you finish receiving and when you start sending • We will wait for 1 second for a reply from each group • Be aware that you may not receive anything for that time • it can be much longer than that before you receive a message for your own group • Please do not send in other people’s time • The RF modules cannot determine which is the correct signal and the messages will get messed
Testing • The base station will stay on for the whole week before the lab is due – front row • Sending and receiving messages will be printed on the screen • The TA’s will transmit as the last group (group 7) • This is to check that the BS is actually transmitting • If you don’t see the TA group message, the base station may not actually be transmitting • We will try to check on it, but if there is a problem, please email us
Academic Misconduct • Reports and demos are submitted as a group, but it is a SINGLE group effort • You may talk with other groups but sharing code or reports is NOT ALLOWED • Copying code/reports from previous years is also NOT ALLOWED • If we find copying we are REQUIRED to report it