I´m working with the TWR-KM34Z50MV3, and I want to read 7 signals using the 4 SD ADC and 3 SAR ADC of the board.
Know I´m trying to configure the SAR ADC´s using the MKMxxZxxACxx5 Bare Metal Software Drivers R4.1.5, but I can´t deal with the configuration, beacause if I want to use all channel they must to be triggered by HW.
I´ve set the ADC_Init(cfg,avg,CHA,CHB,CHC,CHD,ip,callback) as follows:
ADC_Init (ADC_MODULE_16B_HWTRG_IREF_CONFIG,
HWAVG_OFF,
ADC_CH_SE_IRQ_CONFIG(AD10),
ADC_CH_SE_IRQ_CONFIG(AD0),
ADC_CH_SE_IRQ_CONFIG(AD1),
ADC_CH_SE_IRQ_CONFIG(AD2),
PRI_LVL0,
(ADC_CALLBACK) Callback_ADC);
but the ADC Callback doesn´t run.
Do I have to do something with the callback function?
I have attached minimalist software example for your use-case - reading 7 signals using the 4 SD ADC and 3 SAR ADC of the board.
Examples initializes along with other on-chip peripherals also 4ch SD ADC to run with a slight phase shift and gathering 4 measurements at rate of 6 ksps. Each SD ADC channel triggers respective SAR ADC channel and this way up to 8 samples can be gathered of the board in the precise time sequence.
If you need to trigger SAR ADC with more flexibility, you can insert a QuadTimer channel into every SD ADC=> SAR ADC channel chain as Rong suggested. Also as Rong said, the only limitation is that you cannot request SAR ADC to perform more conversions simultaneously because there is only one instance of the analogue block on the MKM34 devices accompanied with four result registers.
Examples further transforms all measured values into Q8.23 fractional format.
Can you tell me where I can download the "MKMxxZxxACxx5 Bare Metal Software Drivers R4.1.5"? Regarding your ADC init function:
ADC_Init (ADC_MODULE_16B_HWTRG_IREF_CONFIG,
HWAVG_OFF,
ADC_CH_SE_IRQ_CONFIG(AD10),
ADC_CH_SE_IRQ_CONFIG(AD0),
ADC_CH_SE_IRQ_CONFIG(AD1),
ADC_CH_SE_IRQ_CONFIG(AD2),
PRI_LVL0,
(ADC_CALLBACK) Callback_ADC);
From api function itself, it is okay, but it is difficult to implement.
As you know that the ADC16 module support Ping-Pong-Pong-Pong mode with hardware triggering, in other words, the ADC16 module has ADC16_SC0, ADC16_SC1, ADC16_SC2, ADC16_SC3 register, which specify the respective sampling channels, you have to trigger the ADC with 4 sequential pulse, the pulses are from the crossbar, the ADC triggering pulses are called "SAR ADC trigger select A pulse", "SAR ADC trigger select B pulse", "SAR ADC trigger select C pulse" and "SAR ADC trigger select D pulse", the delay between the sequential pulse must be greater than conversion time. The problem is that it is difficult to generate 4 pulses with programmable delay, maybe you say that quadTimer can generate the 4 pulses, but the issue is that the 4 timer in one quadTimer module are independent timer, there is NOT a synchronization mechanism. The quadTimer supports master-slave mode, maybe it is okay to generate 4 pulse with programmable delay, but I never test it.
For simplicity, you can use PIT, quadtimer to generate only one pulse and have ADC16 sample one channel, it is easy. In other words, if you want to use hardware trigger, you have to configure the hardware triggering source for example PIT, initialize the crossbar so that you can trigger ADC.
For example, if you want to use PIT0 as "SAR ADC trigger select A pulse", you can write:
I do not think you can use PIT0_CH0/PIT0_CH1 and PIT1_CH0/PIT1_CH1 to trigger ADC four times in sequential way, if you set the PIT in independent mode, the four PIT timers will have different cycle time. The PIT chained mode is in fact a cascading mode, it is useless.
But maybe you can use quadTimer to generate the sequential pulses in master-slave mode, but I have not the code. I will try to develop the example next week, I will update here no matter whether the solution is okay or not.
BR
Xiangjun rong
0
项奖励
回复
'
var data = div.getElementsByClassName("video-js");
var script = document.createElement('script');
script.src = "https://players.brightcove.net/" + data_account + "/" + data_palyer + "_default/index.min.js";
for(var i=0;i< data.length;i++){
videodata.push(data[i]);
}
}
}
for(var i=0;i< videodata.length;i++){
document.getElementsByClassName('lia-vid-container')[i].innerHTML = videodata[i].outerHTML;
document.body.appendChild(script);
}
}
catch(e){
}
/* Re compile html */
$compile(rootElement.querySelectorAll('div.lia-message-body-content')[0])($scope);
}
if (code_l.toLowerCase() != newBody.getAttribute("slang").toLowerCase()) {
/* Adding Translation flag */
var tr_obj = $filter('filter')($scope.sourceLangList, function (obj_l) {
return obj_l.code.toLowerCase() === newBody.getAttribute("slang").toLowerCase()
});
if (tr_obj.length > 0) {
tr_text = "内容由 lilicon-trans-text 使用 AI 辅助工具翻译".replace(/lilicon-trans-text/g, tr_obj[0].title);
tr_text +='查看原文';
try {
if ($scope.wootMessages[$rootScope.profLang] != undefined) {
tr_text = $scope.wootMessages[$rootScope.profLang].replace(/lilicon-trans-text/g, tr_obj[0].title);
tr_text +='查看原文';
}
} catch (e) {
}
} else {
//tr_text = "This message was translated for your convenience!";
tr_text = "lilicon-trans.your.convenience";
}
try {
if (!document.getElementById("tr-msz-" + value)) {
var tr_para = document.createElement("P");
tr_para.setAttribute("id", "tr-msz-" + value);
tr_para.setAttribute("class", "tr-msz");
tr_para.style.textAlign = 'justify';
var tr_fTag = document.createElement("IMG");
tr_fTag.setAttribute("class", "tFlag");
tr_fTag.setAttribute("alt", "翻译图标");
// tr_fTag.setAttribute("title", "翻译图标免责声明");
tr_fTag.setAttribute("src", "/html/assets/translate-icon.svg");
tr_para.appendChild(tr_fTag);
var container = document.createElement('span');
container.innerHTML = tr_text;
//var tr_textNode = document.createTextNode(container);
tr_para.appendChild(container);
/* Woot message only for multi source */
if(rootElement.querySelector(".lia-message-body-content").previousElementSibling != null && rootElement.querySelector(".lia-message-body-content").previousElementSibling.getAttributeNames().includes("data-generation-timestamp")){
rootElement.querySelector(".lia-message-body-content").previousElementSibling.remove()
}
if(rootElement.querySelector(".lia-quilt-forum-message")){
rootElement.querySelector(".lia-quilt-forum-message .lia-message-body").insertBefore(tr_para,rootElement.querySelector(".lia-message-body-content"));
} else if(rootElement.querySelector(".lia-message-view-blog-topic-message")) {
rootElement.querySelector(".lia-message-view-blog-topic-message .lia-message-body").insertBefore(tr_para,rootElement.querySelector(".lia-message-body-content"));
} else if(rootElement.querySelector(".lia-quilt-blog-reply-message")){
rootElement.querySelector(".lia-quilt-blog-reply-message .lia-message-body").insertBefore(tr_para,rootElement.querySelector(".lia-message-body-content"));
} else if(rootElement.querySelector(".lia-quilt-tkb-message")){
rootElement.querySelectorAll(".lia-quilt-tkb-message .lia-message-body")[0].insertBefore(tr_para,rootElement.querySelector(".lia-message-body-content"));
} else if(rootElement.querySelector(".lia-quilt-tkb-reply-message")){
rootElement.querySelectorAll(".lia-quilt-tkb-reply-message .lia-message-body")[0].insertBefore(tr_para,rootElement.querySelector(".lia-message-body-content"));
} else if(rootElement.querySelector(".lia-quilt-idea-message")){
rootElement.querySelector(".lia-quilt-idea-message .lia-message-body").insertBefore(tr_para,rootElement.querySelector(".lia-message-body-content"));
} else if(rootElement.querySelector(".lia-quilt-idea-reply-message")){
rootElement.querySelector(".lia-quilt-idea-reply-message .lia-message-body").insertBefore(tr_para,rootElement.querySelector(".lia-message-body-content"));
} else if(rootElement.querySelector('.lia-quilt-occasion-message')){
rootElement.querySelector('.lia-quilt-occasion-message .lia-message-body').insertBefore(tr_para,rootElement.querySelector(".lia-message-body-content"));
}
else {
if (rootElement.querySelectorAll('div.lia-quilt-row-footer').length > 0) {
rootElement.querySelectorAll('div.lia-quilt-row-footer')[0].appendChild(tr_para);
} else {
rootElement.querySelectorAll('div.lia-quilt-column-message-footer')[0].appendChild(tr_para);
}
}
}
} catch (e) {
}
}
} else {
/* Do not display button for same language */
// syncList.remove(value);
var index = $scope.syncList.indexOf(value);
if (index > -1) {
$scope.syncList.splice(index, 1);
}
}
}
}
}
}
/*if(mszList_l.length <= 0){
setTimeout(()=>{
var mszListl = [];
angular.forEach(document.querySelectorAll("[class*='lia-js-data-messageUid']"), function(element) {
var mszId = element.getAttribute("data-lia-message-uid");
if (mszId != null) {
mszListl.push(mszId);
}
});
var mszListid = mszListl;
console.log("mszListl:",mszListl);
},2000)
}else{
var mszListid = mszList_l;
}*/
console.log("mszList_l:",mszList_l.length);
angular.forEach(mszList_l, function (value) {
if (document.querySelectorAll('div.lia-js-data-messageUid-' + value).length > 0) {
var rootElements = document.querySelectorAll('div.lia-js-data-messageUid-' + value);
}else if(document.querySelectorAll('.lia-occasion-message-view .lia-component-occasion-message-view').length >0){
var rootElements = document.querySelectorAll('.lia-occasion-message-view .lia-component-occasion-message-view')[0].querySelectorAll('.lia-occasion-description')[0];
}else {
var rootElements = document.querySelectorAll('div.message-uid-' + value);
}
angular.forEach(rootElements, function (rootElement) {
if (value == '529468' && "ForumTopicPage" == "TkbArticlePage") {
rootElement = document.querySelector('.lia-thread-topic');
}
/* V1.1 Remove from UI */
if (document.getElementById("tr-msz-" + value)) {
document.getElementById("tr-msz-" + value).remove();
}
if (document.getElementById("tr-sync-" + value)) {
document.getElementById("tr-sync-" + value).remove();
}
/* XPath expression for subject and Body */
var lingoRBExp = "//lingo-body[@id = "+"'lingo-body-"+value+"'"+"]";
lingoRSExp = "//lingo-sub[@id = "+"'lingo-sub-"+value+"'"+"]";
/* Get translated subject of the message */
lingoRSXML = doc.evaluate(lingoRSExp, doc, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
for(var i=0;i 0){
angular.forEach(document.querySelectorAll(".PageTitle"), function(subEle) {
subEle.textContent = sub_L;
});
}
}
}
// Label translation
try{
var labelEle = document.querySelector("#labelsForMessage");
if(!labelEle){
labelEle = document.querySelector(".LabelsList");
}
if(labelEle) {
var listContains = labelEle.querySelector('.label');
if (listContains) {
/* Commenting this code as bussiness want to point search with source language label */
// var tagHLink = labelEle.querySelectorAll(".label")[0].querySelector(".label-link").href.split("label-name")[0];
var lingoLabelExp = "//lingo-label/text()";
trLabels = [];
trLabelsHtml = "";
/* Get translated labels of the message */
lingoLXML = doc.evaluate(lingoLabelExp, doc, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
var labelsLength = document.querySelector(".LabelsList").querySelectorAll(".label").length;
var labelSnapshotLength = lingoLXML.snapshotLength;
if (labelsLength == labelSnapshotLength){
for (var k = 0; k < lingoLXML.snapshotLength; k++) {
//trLabels.push(lingoLXML.snapshotItem(i).textContent);
if (k != 0) {
//trLabelsHtml = trLabelsHtml + '