Sunday, July 21, 2019

UPDATE: Solar Powered Weather Station - 3. nRF52 Programming Progress & SES Config

nRF52 Programming Progress

After getting some good advice from members of EEVblog/Nordic/reddit and burning a bit of time with my crude nRF52 dev kit I have managed to make some good progress in terms of programming the nRF52832. So here is what I have completed thus far and what I still have left to do:

Task Complete? Notes
LED Blinky Yes Pin config is quite simple
LED PWM Yes Pin config is a bit more complex here
UART Comms Yes As always make sure your logic voltage levels are compatible
ADC Read no Will be used to monitor voltage of supercapacitor
BME280 Comms Yes I2C/TWI up and running :D
SGP30 Comms ~ Basic function working, need to add humidity compensaiton
BLE Comms ~ Have done some basic tests with making a BLE peripheral

Reading data from BME280 (Temperature, Pressure, & Humidity)

Reading data from SGP30 (tVOC & eqC02)

SGP30 testing in Hong Kong


Segger Embedded Studio (SES) Configuration

Also I have found out that setting up a completely new nRF52 projects in SES is not so simple, your best bet is to copy and modify an example project that resembles what you want to achieve. Here & here are a couple of suggestions on how to create a new nRF52 project in SES, also below is my summary that has worked well so far:
  1. Download the nRF52 SDK and place it not so deep in the main drive: 
    • C:\NORDIC\nRF5_SDK_15.2.0
  2. Make up a working directory near same folder, again this can't be too deep into your main drive: 
    • C:\NORDIC\_WorkDir
  3. In the working directory create a project folder, for example when I was testing the PWM function I worked out of:
    • C:\NORDIC\_WorkDir\11_2019May21_PWM-test_v12a
  4. In the examples folder of the SDK find a project that closely resembles what you want to achieve, then copy the following files into your project folder:
    • C:\NORDIC\nRF5_SDK_15.2.0\examples\peripheral\pwm_driver\pca10040\blank\ses\pwm_driver_pca10040.emProject
    • C:\NORDIC\nRF5_SDK_15.2.0\examples\peripheral\pwm_driver\pca10040\blank\ses\flash_placement.xml
    • C:\NORDIC\nRF5_SDK_15.2.0\examples\peripheral\pwm_driver\main.c
    • C:\NORDIC\nRF5_SDK_15.2.0\examples\peripheral\pwm_driver\pca10040\blank\config\sdk_config.h
  5. Now your project folder should look something like:
    • C:\NORDIC\_WorkDir\11_2019May21_PWM-test_v12a\pwm_driver_pca10040.emProject
    • C:\NORDIC\_WorkDir\11_2019May21_PWM-test_v12a\flash_placement.xml
    • C:\NORDIC\_WorkDir\11_2019May21_PWM-test_v12a\main.c
    • C:\NORDIC\_WorkDir\11_2019May21_PWM-test_v12a\sdk_config.h
  6. Rename the SES project in explorer: "pwm_driver_pca10040.emProject" to "PWM-test.emProject"
  7. Open up the renamed SES project in a txt editor and change the following:
    • "<solution Name="pwm_driver_pca10040" target="8" version="2">" to "<solution Name="PWM-test" target="8" version="2">"
    • "<project Name="pwm_driver_pca10040">" to "<project Name="PWM-test">"
    • If using a custom board make sure to state this in "c_preprocessor_definitions": "c_preprocessor_definitions="BOARD_PCA10040;" to "c_preprocessor_definitions="BOARD_CUSTOM;"
    • Using the find & replace function of your txt editor change the path depth of all mentioned files/libraries/directories so that they agree with your nRF52 SDK directory: "../../../../../../" to "../../nRF5_SDK_15.2.0/"
    • Update the directory of "main.c": "<file file_name="../../../main.c" />" to "<file file_name="main.c" />"
    • Update the directory of "sdk_config.h": "<file file_name="../config/sdk_config.h" />" to "<file file_name="sdk_config.h" />"
    • Lastly update "c_user_include_directories" so that it looks at the correct directory for "sdk_config.h": "c_user_include_directories="../../../config;" to "c_user_include_directories=".;"
  8. Try opening up the updated project in SES and hitting the compile button (F7), given that everything has been done correctly the project should compile without any issues

No comments:

Post a Comment