CMUAbstract / tab

TAB reference implementations, examples, and documentation
Other
0 stars 0 forks source link

Add HSE clock initialization function to CDH example #2

Open mablem8 opened 1 year ago

mablem8 commented 1 year ago

In cdh.h, add the function void init_clock_hse(void);.

In cdh.c, add the function implementation.

Test the cdh_monolithic.c program after replacing init_clock(); with init_clock_hse();.

AnandAlok0807 commented 1 year ago

HSE clock initialization function changes are :

  1. cdh_monolithic.c --> HSE clock init and master clock output (MCO) pin configuration to test output configured clock frequency.
  2. cdh.c --> function to implement HSE clock configuration and frequency setup
  3. cdh.h --> initclock_hse function declaration

Issue link : https://github.com/CMUAbstract/tab/issues/2#issue-1574697830 Commit HASH link : [56e88fa](https://github.com/CMUAbstract/tab/commit/56e88fa0ffe3cd95ebe8d8c514389492a840576d)

mablem8 commented 1 year ago

Commit 56e88fa0ffe3cd95ebe8d8c514389492a840576d addresses this issue by

  1. Adding the HSE clock initialization function header here,
  2. Adding the HSE clock initialization function implementation here, and
  3. Using the HSE clock initialization function here.

However, 56e88fa0ffe3cd95ebe8d8c514389492a840576d introduces extraneous code in cdh_monolithic.c from line 28 through line 52. While this code may be useful for testing, it cannot be present in a TAB example program.

Add the HSE clock initialization function header, the HSE clock initialization function implementation, and the use of the HSE clock initialization function to a commit in the sprint-1_alok branch. Omit the superfluous code. Then post a link to the new commit as a comment in this issue thread.

AnandAlok0807 commented 1 year ago

Commit 76196ee fixes issue-2

  1. Superfluous HSE test code removed cdh_monolithic.c
  2. HSE function code cdh.c
  3. HSE function cdh.h
mablem8 commented 1 year ago

The changes look good, however when I test the commit with tx_example.py the program hangs.

Could you post the terminal output here once you've confirmed that the changes work on your end?

AnandAlok0807 commented 1 year ago

Commit ccdb3dd fixes issue related to - no response to TAB commands

  1. Changes done in cdh.c at line

HSE clock test results : HSE_clock_initialization_test_result

mablem8 commented 1 year ago

I see no change in test behavior on my end using the following commands:

cd c-examples/cdh-monolithic/
cd ../scripts/
source sourcefile.txt
cd ../cdh-monolithic/
make
st-flash write cdh-monolithic.bin 0x08000000
cd ../../python-examples/tx/
source ../p3-env/bin/activate
python3 tx_example.py /dev/ttyUSB0

The expected output is a sequence of commands and replies. Here are the results from the sprint-2 branch:

txcmd: common_ack hw_id:0x1234 msg_id:0x0000 src:gnd dst:cdh
reply: common_ack hw_id:0x1234 msg_id:0x0000 src:cdh dst:gnd

txcmd: common_nack hw_id:0x1234 msg_id:0x0001 src:gnd dst:cdh
reply: common_nack hw_id:0x1234 msg_id:0x0001 src:cdh dst:gnd

txcmd: common_debug hw_id:0x1234 msg_id:0x0002 src:gnd dst:cdh "Hello, world!"
reply: common_debug hw_id:0x1234 msg_id:0x0002 src:cdh dst:gnd "Hello, world!"

txcmd: common_data hw_id:0x1234 msg_id:0x0003 src:gnd dst:cdh 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0a 0x0b
reply: common_ack hw_id:0x1234 msg_id:0x0003 src:cdh dst:gnd

txcmd: common_data hw_id:0x1234 msg_id:0x0004 src:gnd dst:cdh 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x0a 0x09 0x0b
reply: common_nack hw_id:0x1234 msg_id:0x0004 src:cdh dst:gnd

The ccdb3ddace33c206c94d8b9e208afea33f7bda4f commit hangs without a reply to the first command.

In future posts, include code snippets inside the comment and embed any images too; that way, they can be viewed directly instead of clicking through to a PDF.

AnandAlok0807 commented 1 year ago

Commit 2cb9494 addresses HSE clock initialization function issue.

  1. Adding the HSE clock initialization function implementation in cdh.c at line 177-200

  2. HSE clock initialization function header cdh.h at line 44

  3. HSE clock initialization function call cdh_monolithic.c at line 22

mablem8 commented 1 year ago

When I compile the sprint 5 commit (f9530b2db5faf7fb95218ce40776bad08ef6a929) and flash it to the CDH MCU, LED1 lights up and LED2 stays unlit after powering the board. When I test the board with the test script, all commands receive the expected reply.

When I compile commit 2cb94941ec4cdbc35b01dcf37bcc866aeec4f5bb and flash it to the CDH MCU, neither of the LEDs light up after powering the board. When I test the board with the test script, I don’t receive any replies.

Because the init_leds function is called directly after the init_clock_hse function, and because the LEDs don't light up after flashing the HSE version of the program to the MCU, it seems that something is going wrong before the init_leds function is called.

What behavior are you observing on your board?

AnandAlok0807 commented 1 year ago

Updated commit for fixing missing upload in ff068cd addresses HSE clock function issue.

Adding the HSE clock initialization function implementation in cdh.c

HSE clock initialization function call cdh_monolithic.c