28
EEL 4744 Microprocessor Applica1ons Serial Communica1on Interface Presented by: Damian Szmulewicz University of Florida

EEL4744# Microprocessor#Applicaons# …Sources • TISPRS439F:#DataManual# • TISPRUFZ5A:#2823x#Serial#Communicaons#Interface# (SCI)#Reference#Guide.# – Pages:#12T16,#21T22,#26T35#

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

  • EEL  4744  Microprocessor  Applica1ons  

     

    Serial  Communica1on  Interface  

     Presented  by:  Damian  Szmulewicz  

    University  of  Florida    

  • Sources  

    •  TI  SPRS439F:  Data  Manual  

    •  TI  SPRUFZ5A:  2823x  Serial  Communica1ons  Interface  (SCI)  Reference  Guide.  –  Pages:  12-‐16,  21-‐22,  26-‐35  

    •  TI  SPRUB0C:  System  Control  and  Interrupt  Reference  Guide.  –  Pages:  122,  123,  133,  139-‐142  

     

  • SCI  Module  Overview  

  • SCI  Module  Signals  

  • Lab-‐Related  SCI  Module  Features  •  Two  external  pins:  

    –   SCITXD:  SCI  transmit-‐output  pin  –   SCIRXD:  SCI  receive-‐input  pin  –  Both  pins  can  be  used  as  GPIO  if  not  used  for  SCI.  

    •  Baud  rate  programmable  to  64K  different  rates  •  Data-‐word  format  

    –   One  start  bit  –   Data-‐word  length  programmable  from  one  to  eight  bits  –   Op1onal  even/odd/no  parity  bit  –  One  or  two  stop  bits  –  Four  error-‐detec1on  flags:  parity,  overrun,  framing,  and  break  detec1on  

     

  • Lab-‐Related  SCI  Module  Features  •  Transmiaer  and  receiver  opera1ons  can  be  accomplished  through  interrupt-‐  driven  or  polled  algorithms  with  status  flags.  

    •  Separate  enable  bits  for  transmiaer  and  receiver  interrupts  (except  BRKDT)  

    •  13  SCI  module  control  registers  located  in  the  control  register  frame  beginning  at  address  7050h  

  • SCI  Peripherals  and  Registers  •  SCIA  and  SCIB  

    – We  have  SCIB  connected  to  the  UART  in  our  DSP  board:  

  • SCI  Communica1on  Example  

  • Data  Format  •  Two  formats:  

    –  Idle-‐line  Mode  

  • Programming  Data  Format  

    •  Register:  SCICCR  (0x7750)  

    •  For  Lab  8:    –  1  stop  bit  –  No  parity  –  N  =  8  bits    

  • Baud  Rate  Calcula1ons  

    •  Internally  generated  serial  clock  determined  by:  –   Low-‐speed  peripheral  clock  LSPCLK  –  Baud-‐select  registers  

       

  • Baud  Rate  Calcula1ons  

    •  Low  Speed  System  Clock:  –  Low-‐Speed  Peripheral  Clock  Pre-‐Scaler  Register  =  0x701B  

    •  EALLOW  Protected      

       

  • Baud  Rate  Calcula1ons  Example  

    –  Given  a  12Mhz  external  clock,  calculate  the  BRR  value  for  a  Baud  rate  =  4800.  Assume  LSPCLK  register  is  set  to  001.  

    –  LSPCLK  =  SYSCLKOUT/2  =  External  Clock/4  =  12MHz/4  =  3MHz  

    BRR  =  3000000/(4800  *  8)  -‐1  =  78  decimal  

     

       

  • Baud  Rate  Register  

    •  SCIHBAUD  :  0x7752,  SCIBAUD  :  0x7753    

       

  • SCI  Control  Register  1  (SCICTL1)    

    •  Controls  the  receiver/transmiaer  enable,  TXWAKE  and  SLEEP  func1ons,  and  the  SCI  sohware  reset.    

    •  For  lab:  Need  to  enable  Tx  and  Rx  bits  (0  and  1)  and  re-‐enable  the  SCI  by  wri1ng  a  1  to  bit  5  of  this  register.  

       

       

  • How  to  Transmit  a  Character  (Polling)  ?  

    •  Ini1alize  SCI  Registers  •  Check  the  Transmiaer  buffer  register  ready  flag  (bit  7  of  SCICTL2  =  0x7754  

    •  When  SCICTL2  is  set,  the  SCITXBUF  is  ready  to  receive  a  character.    

    •  Wri1ng  data  to  the  SCITXBUF  automa1cally  clears  this  bit.    

    •  Wait  for  buffer  to  clear  (SCICTL2  bit  7  =1)  ,  then  send  another  character  to  SCITXBUFF.  

  • SCI  Interrupt  Controlled  

    •  The  SCICTL2  register  has  one  flag  bit  (TXRDY)  that  indicates  ac1ve  interrupt  condi1ons,  and  the  SCIRXST  register  has  two  interrupt  flag  bits  (RXRDY  and  BRKDT)  

    •  The  transmiaer  and  receiver  have  separate  interrupt-‐enable  bits  

         

  • Interrupt  Using  the  PIE  block  The peripheral interrupt expansion (PIE) block multiplexes numerous interrupt sources into a smaller set of interrupt inputs

  • The  PIE  Muxed  Table  

    •  Shows  which  interrupt  is  connected  to  which  peripheral:  

         

  • The  PIE  Vector  Table  

    •  Shows  address  of  interrupt  vectors  and  func1on    

         

  • Interrupt  Using  the  PIE  block  

  • PIE  Configura1on  and  Control  Reg.  

    •  The  registers  controlling  the  func1onality  of  the  PIE  block:  

  • PIECTL  and  PIEACK  

    •  PIECTL  is  used  to  enable  vector  fetching  from  PIE  vector  table  (bit  0).  

    •  PIEACK  :    –  If  a  bit  reads  as  a  0,  it  indicates  that  the  PIE  can  send  an  interrupt  from  the  respec1ve  group  to  the  CPU.  

    –  Reading  a  1  indicates  if  an  interrupt  from  the  respec1ve  group  has  been  sent  to  the  CPU  and  all  other  interrupts  from  the  group  are  currently  blocked.  

    – Wri1ng  a  1  to  the  respec1ve  interrupt  bit  clears  the  bit  and  enables  the  PIE  block  to  drive  a  pulse  into  the  CPU  interrupt  input  if  an  interrupt  is  pending  for  that  group.  

  • PIEIER  and  PIEIFR  

    •  PIEIER  is  used  to  enable  an  interrupt  within  a  group  (x.1,  x.2,  x.3,  etc)  .  

    •  PIEIFR  bits  indicate  whether  an  interrupt  is  currently  ac1ve.  

    •  For  Interrupt  9:    –  PIEIER9  =  0x0CF2  –  PIEIFR9  =  0x0CF3  

    •  For  more  info  please  refer  to  TI  SPRUB0C.    

  • How  to  Transmit  a  Character  (Interrupt  based)  ?  

    •  Set  the  PIECTL  register  to  use  PIE  vectors  instead  of  CPU  vectors.  This  allows  Rx  and  Tx  to  have  separate  ISR.  

    •  Set  INT  vectors  to  start  of  memory  map  (CLRC  VMAP)  •  Enable  INT9  on  IER  •  Load  Interrupt  vector  (0x0DC4)  with  Rx_ISR  address  •  Load  Interrupt  vector  (0x0DC6)  with  Tx_ISR  address  •  Ini1alize  SCI  Registers  •  Turn  on  Rx  and  Tx  INTs  on  SCICTL2  •  Turn  on  Rx  and  Tx  on  SCICTL1  •  Enable  SCI  (bit  5  of  SCICTL1)  

  • How  to  Transmit  a  Character  (Interrupt  based)  ?  

    •  In  the  TxISR:    –  Load  SCITXBUF  –  Turn  off  Tx  INT  in  PIEIER9  –  Turn  on  Rx  INT  in  PIEIER9  –  Clear  INT9  PIE  group  in  PIEACK  (bit  8)  

    •  In  the  RxISR:    –  Load  SCIRxBUF  –  Turn  off  Rx  INT  in  PIEIER9  –  Turn  on  Tx  INT  in  PIEIER9  –  Clear  INT9  PIE  group  in  PIEACK  (bit  8)  

  • Final  Remarks    

    •  PIE  registers  are  EALLOW  protected  

    •  Don’t  forget  to  set  the  GPxMUXs  for  SCIB  

    •  Don’t  forget  to  turn  on  the  SCIB  clock    –  Bit  11  of  PCLKCR0  register  

  • Ques1ons???