NetBurner Analog to Digital Converter MCF5282 ColdFire Microcontroller User’s manual
NetBurner Board
NetBurner Connector J3 – ADC input/output
ADC Pins C:\Nburn\docs\platform\Mod5282.html {NetBurner Carrier Board Schematic (pdf)}
NetBurner Memory map C:\Nburn\docs\platform\Mod5282.html {Mod5282 Memory Map}
Port QA
Port QB
QPR: See Table27-7
See Table 27-7
See Table 27-9
Status Registers See Section for details
See Section for details
See Section for details
NetBurner Memory map C:\Nburn\docs\platform\Mod5282.html {Mod5282 Memory Map}
C++ sim Object of type MCF5282 C++ Header File is: C:\Nburn\MOD5282\system\sim5282.h /********************************************************************** * * MCF5282 ColdFire Assembly Header File * * **********************************************************************/ #define MBASE 0x /* Module Base Address*/ extern volatile mcf5282 sim; /* main struct */ typedef struct {... qadcstruct qadc; /* 1x >1x1903FF */... } mcf5282 ; typedef struct { /* queued analog-to-digital converter module */... } qadcstruct ;
ADC Struct typedef struct { /* queued analog-to-digital converter module */ vuword qadcmcr; /* > qadc module configuration register */ vubyte pack00[4]; /* > */ vubyte portqa; /* > (qa) port data register */ vubyte portqb; /* > (qb) port data register */ vubyte ddrqa; /* > port qa data direction register */ vubyte ddrqb; /* > port qb data direction register */ vuword qacr0; /* 19000a->19000b qadc control register 0 */ vuword qacr1; /* 19000c->19000d qadc control register 1 */ vuword qacr2; /* 19000e->19000f qadc control register 2 */ vuword qasr0; /* > qadc status register 0 */ vuword qasr1; /* > qadc status register 1 */ vubyte pack01[491]; /* >1901ff */ vuword ccw[64]; /* > conversion command word table */ vuword rjurr[64]; /* > right-justified unsigned result register */ vuword ljsrr[64]; /* > left-justified signed result register */ vuword ljurr[64]; /* > left-justified unsigned result register */ } qadcstruct ;
Mod5282 A/D Example – C:\Nburn\docs\platform\Mod5282.html Set up A/D to Continuously sample all 8 channels and store the results /*************************************************** * * Copyright 2003, 2004, 2005 NetBurner, Inc. * ALL RIGHTS RESERVED * * Permission is hereby granted to purchasers of * NetBurner Hardware to use or modify this * computer program for any use as long as the * resultant program is only executed on NetBurner * provided hardware. * * No other rights to use this program or its * derivatives in part or in whole are granted. * ********************************************************/ #include "predef.h" #include extern "C" { void UserMain(void * pd); } /* Set up A/D to continuously sample all 8 channels and store the results */ /* See the Motorola 5282 User Manual - Chapter 27 for additional information. */ void InitializeQADC() { sim.qadc.qadcmcr=0x8000; sim.qadc.portqa=0; sim.qadc.portqb=0; sim.qadc.ddrqa=0; sim.qadc.ddrqb=0; sim.qadc.qacr0=0x7F; /* Divide by Mhz -> 500Khz AD clock */ sim.qadc.qacr1=0x1100; /* Continious software scans in queue 1 */ sim.qadc.qacr2=11; /*disabled queue 2 with Queue 1 ending at position 11 */ sim.qadc.qasr0=0; sim.qadc.qadcmcr=0x0000; asm(" nop"); sim.qadc.ccw[0]=0xC0; /*Convert channel 0. See the Motorola 5282 User Manual - Table */ sim.qadc.ccw[1]=0xC1; sim.qadc.ccw[2]=0xC2; sim.qadc.ccw[3]=0xC3; sim.qadc.ccw[4]=0xF4; sim.qadc.ccw[5]=0xF5; sim.qadc.ccw[6]=0xF7; sim.qadc.ccw[7]=0xF8; sim.qadc.ccw[8]=0xFC; sim.qadc.ccw[9]=0xFD; /* Should return a measured 0 */ sim.qadc.ccw[10]=0xFE; /* Should return a measured 1023 or max */ sim.qadc.ccw[11]=0xFF; /* Should return half scale or 512 */ sim.qadc.qacr1=0x1100; /* Continious software scans in queue 1 */ } /* Return the converted samples See Motorola 5282 User Manual Section */ WORD GetQADC(int ch) { return sim.qadc.rjurr[ch]; } void UserMain(void * pd) { InitializeStack(); if (EthernetIP==0)GetDHCPAddress(); OSChangePrio(MAIN_PRIO); EnableAutoUpdate(); /* Start up the A/D system */ InitializeQADC(); iprintf("Application started\n"); while (1) { OSTimeDly(20); iprintf("A/D values. Floating point voltage assumes a 5.0V reference\r\n"); for (int i=0; i<8; i++) { WORD v=GetQADC(i); float f=v; f=f*5.0/1024.0; printf("AD[%d] = 0x%03X or %4d or %4.2fV \r\n",i,v,v,f); } /******************************************************************** End of the NetBurner Mod5282 A/D Example Program *********************************************************************/