lab 7 – serial rf communication

Post on 04-Jan-2016

48 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

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 - PowerPoint PPT Presentation

TRANSCRIPT

Lab 7 – Serial RF Communication

Start date: Week #10Due date: Week #11

1

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)

2

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 bitsSC0 is in use – communication with terminal

3

Registers

SC0CR1/SC1CR1 Mode Parity

SC0CR2/SC1CR2 Transmit and receive enables Interrupt enables

SC0SR1/SC1SR1 Flags for complete and errors

4

Registers

SC0DRH/L / SC1DRH/L Register to send/receive data through

SCI We will be using 8 data bits, so only

low is required

5

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

6

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 boardWarning: 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

7

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

8

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)

9

Message Passing

Base station sends out message to a groupThat group stores/prints the message and replies The base station stores/prints the message and repliesThe group stores/prints the message

10

Message Format – Base Station

Base Station 1st send Message SOH GroupXX STX Message ETX EOT

11

Message Format - groupXX

Group Reply STX Some message less than 20 chars ETX EOT

12

Message Format – Base Station

Base Station Reply to group SOH GroupXX STX Some other message ETX EOT

13

Summary of message passing

14

General Notes / Hints

Please put a short delay between when you finish receiving and when you start sendingWe 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

15

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

16

Academic Misconduct

Reports and demos are submitted as a group, but it is a SINGLE group effortYou may talk with other groups but sharing code or reports is NOT ALLOWEDCopying code/reports from previous years is also NOT ALLOWEDIf we find copying we are REQUIRED to report it

17

top related