Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update AMDS Firmware for Timing Manager in AMDC #48

Merged
merged 6 commits into from
Sep 13, 2024

Conversation

codecubepi
Copy link
Contributor

@codecubepi codecubepi commented May 10, 2024

This PR is a mild revision to the AMDS Firmware that makes its side of the interface compatible with the new AMDS driver and new Timing Manager IPs introduced in v1.3 of the AMDC Firmware.

This is a relatively small code change on the AMDS firmware side. The code that is called to transmit the data from the AMDS to the AMDC driver over UART was previously in an interrupt context. Now that the data transmission is meant to happen as soon as all the daughtercards have been sampled, this code is no longer executed by its own interrupt.

Therefore, the UART transmission ISR has been moved into the function "transmit_samples()", which is called from the ADC sync interrupt context after sampling is completed.

Making this change also allowed me to remove the "ignore next sample" issue, since the sampling will no longer go out-of-sync with the PWM carrier due to data transmission.

I still need to update docs.amdc.dev page on the AMDS' firmware. I will do so once we complete v1.3 in the AMDC repo.

@codecubepi codecubepi self-assigned this May 10, 2024
@codecubepi codecubepi linked an issue May 10, 2024 that may be closed by this pull request
4 tasks
@codecubepi
Copy link
Contributor Author

codecubepi commented May 14, 2024

Hey @codecubepi , this PR needs the following before review & close:

  • Test these changes with the old AMDS driver on the AMDC side for sanity sake
  • Test these changes with the new AMDS driver on the AMDC side for real functionality sake
  • Test after merging Disable the SysTick ISR #49 into this branch
  • When v1.3 in AMDC-Firmware is ready for review, this PR is also ready for final review

@codecubepi codecubepi mentioned this pull request Jun 3, 2024
@codecubepi codecubepi marked this pull request as ready for review June 3, 2024 14:41
Copy link
Collaborator

@npetersen2 npetersen2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @codecubepi.

One comment for us to discuss---I know this code works, has been tested pretty extensively, etc. So, I hesitate to change anything. However, if you read the ADC code, it has some extra complexity with two memory buffers that it ping-pongs between due to the old ISR operation. However, now, since there is only 1 ISR context that does everything, it does not need this complexity. It would be nice to simplify the code a bit, but I am not sure we need to invest the time to do that, test it, etc.... what do you think?

Comment on lines 184 to 191
// Switch read buffer to where we just put the new data,
// therefore, satisfying the property that the read_buffer_number
// always points to a valid set of samples!
read_buffer_number = 1 - read_buffer_number;

// Now that read buffer is set, we are safe to update write buffer
// for the next time this ISR runs...
write_buffer_number = 1 - write_buffer_number;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tab/space issue

@codecubepi
Copy link
Contributor Author

Thanks codecubepi.

One comment for us to discuss---I know this code works, has been tested pretty extensively, etc. So, I hesitate to change anything. However, if you read the ADC code, it has some extra complexity with two memory buffers that it ping-pongs between due to the old ISR operation. However, now, since there is only 1 ISR context that does everything, it does not need this complexity. It would be nice to simplify the code a bit, but I am not sure we need to invest the time to do that, test it, etc.... what do you think?

Well, if I were to fix the code to address the tab/space issue, I might as well just remove the unnecessary buffer code (and do some retesting).

Otherwise it'd be easy to open an issue and have a be a "good first issue" for future contributors... but in all reality it could turn into an issue that never really gets addressed... I think the first option of me just fixing it and retesting is probably the better way to go 🙃

@codecubepi
Copy link
Contributor Author

@npetersen2

I took care of removing those obselete double buffers. I ran a hardware test with the fixed ADC data flushing, to verify that the AMDS data still matches what is seen by the AMDC's on-board ADC:

image

Copy link
Collaborator

@npetersen2 npetersen2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So nice to have clean code :) Thanks @codecubepi

Best code is no code---115 lines removed!

@codecubepi
Copy link
Contributor Author

So nice to have clean code :) Thanks codecubepi

Best code is no code---115 lines removed!

Haha you're welcome. I can delete more if it'll make you even happier 😂

@codecubepi
Copy link
Contributor Author

Note from @elsevers : We should start tagging AMDS releases with a version number that matches the AMDC Firmware version number, so user's know when firmware is compatible. So the previous commit on develop would be tagged v.1.2.x, and this merge would get tagged as v1.3.x.

@npetersen2
Copy link
Collaborator

Per the release of AMDC-Firmware v1.3.0, I believe this PR should be merged, correct @codecubepi ?

@codecubepi
Copy link
Contributor Author

Per the release of AMDC-Firmware v1.3.0, I believe this PR should be merged, correct codecubepi ?

Yes, let's merge this! See my comment above about version tagging in this repo to match AMDC-Firmware.

@codecubepi codecubepi merged commit 88268b7 into develop Sep 13, 2024
@codecubepi codecubepi deleted the feature/io-mgmt-update branch September 13, 2024 20:10
@elsevers
Copy link
Contributor

Note from @elsevers : We should start tagging AMDS releases with a version number that matches the AMDC Firmware version number, so user's know when firmware is compatible. So the previous commit on develop would be tagged v.1.2.x, and this merge would get tagged as v1.3.x.

@codecubepi, I compared notes with @npetersen2 on this and we decided on another approach to handle this. From @npetersen2 's message:

The way you suggested could work, but I worry it will cause too much overhead, and might confuse folks to have X releases that are all exactly the same code... e.g., if the AMDS stays constant, could be easily 10+ releases for "no reason"
The way this is usually done I believe (e.g., in python) is for the AMDS to be released on its own vA.B.C numbering as makes sense, then provide a "requirements" file in the AMDC for each release saying it needs AMDS >= v2 etc.
I could see either way working, but I feel it just adds some overhead to always keep releasing the AMDS when there are no changes, plus I am not sure that codebase will change too much

A future idea would be that the AMDC can query the AMDS at boot-up to determine the firmware version to ensure compatibility 🙂

Since, for now, this is really strictly a user/human issue, I guess keeping it in the docs.amdc.dev website makes sense, probably on the "https://docs.amdc.dev/getting-started/user-guide/amds-interface/" page near the top, a new section about installing the correct AMDS firmware and a table of compatible versions between the AMDS/AMDC

@codecubepi
Copy link
Contributor Author

@elsevers @npetersen2

Yeah, this is a completely fair concern. I'm willing to concede 😄

@elsevers elsevers mentioned this pull request Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update AMDS Interface to AMDC
3 participants