Skip to content

This repository provides a bare-metal code example for using TMR2 as 10kHz clock for SPI, configured as host with 2 clients (RC6 pin ->SS1 and RC7 pin ->SS2).

Notifications You must be signed in to change notification settings

microchip-pic-avr-examples/pic18f47q10-cnano-tmr2-spi-clock-bare

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MCHP

PIC18F47Q10 Using TMR2 as Alternate SPI clock

The PIC18F47Q10 features Three 8-bit Timers/Counters and two MSSP modules, which can be configured in SPI mode. In this demo, the TMR2 is used as 10kHz clock for SPI, configured as host with 2 clients (RC6 pin ->SS1 and RC7 pin ->SS2).

Related Documentation

Software Used

Hardware Used

  • PIC18F47Q10 Curiosity Nano (DM182029)
  • An oscilloscope or logic analyzer

Setup

The PIC18F47Q10 Curiosity Nano Development Board (DM182029) is used as the test platform.
HardwareSetup

The following pin configurations must be made for this project:

Pin Configuration
RC3 Digital output SCK
RC4 Digital input SDI
RC5 Digital output SDO
RC6 Digital output SS1
RC7 Digital output SS2

Operation

  1. Calculate the SCK frequency using the formula frequency = 1/Timer2Period/2.
  2. For example for 10kHz frequency = 1/50μS/2 = 10 kHz, this means Timer2Period = 50μS.
  3. Build demo firmware, make and program the generated code onto the PIC18F47Q10 Curiosity Nano.
  4. Run the code, connect an oscilloscope or logic analyzer to the pins:
  • RC3 pin - SCK -> Channel 1 (blue)
  • RC6 pin - SS1 -> Channel 2 (red)
  • RC7 pin - SS2 -> Channel 3 (green)
  1. In the screenshot below, the SCK frequency is 10 kHZ (blue signal).
    oscilloscope

Summary

This project showcases how easy it is to use the TMR2 of PIC18F47Q10 as Alternate SPI clock.

About

This repository provides a bare-metal code example for using TMR2 as 10kHz clock for SPI, configured as host with 2 clients (RC6 pin ->SS1 and RC7 pin ->SS2).

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •