Presentation is loading. Please wait.

Presentation is loading. Please wait.

NetBurner Analog to Digital Converter MCF5282 ColdFire Microcontroller User’s manual.

Similar presentations


Presentation on theme: "NetBurner Analog to Digital Converter MCF5282 ColdFire Microcontroller User’s manual."— Presentation transcript:

1 NetBurner Analog to Digital Converter MCF5282 ColdFire Microcontroller User’s manual

2 NetBurner Board

3 NetBurner Connector J3 – ADC input/output

4 ADC Pins C:\Nburn\docs\platform\Mod5282.html {NetBurner Carrier Board Schematic (pdf)}

5 NetBurner Memory map C:\Nburn\docs\platform\Mod5282.html {Mod5282 Memory Map}

6

7

8 Port QA

9 Port QB

10

11

12

13

14 QPR: See Table27-7

15 See Table 27-7

16 See Table 27-9

17 Status Registers See Section 27.6.6 for details

18 See Section 27.6.7 for details

19 See Section 27.6.8 for details

20

21 NetBurner Memory map C:\Nburn\docs\platform\Mod5282.html {Mod5282 Memory Map}

22

23 C++ sim Object of type MCF5282 C++ Header File is: C:\Nburn\MOD5282\system\sim5282.h /********************************************************************** * * MCF5282 ColdFire Assembly Header File * * **********************************************************************/ #define MBASE 0x40000000 /* Module Base Address*/ extern volatile mcf5282 sim; /* ---------------------- 5282 main struct ------------------------- */ typedef struct {... qadcstruct qadc; /* 1x190000->1x1903FF */... } mcf5282 ; typedef struct { /* queued analog-to-digital converter module */... } qadcstruct ;

24 ADC Struct typedef struct { /* queued analog-to-digital converter module */ vuword qadcmcr; /* 190000->190001 qadc module configuration register */ vubyte pack00[4]; /* 190002->190005 */ vubyte portqa; /* 190006->190006 (qa) port data register */ vubyte portqb; /* 190007->190007 (qb) port data register */ vubyte ddrqa; /* 190008->190008 port qa data direction register */ vubyte ddrqb; /* 190009->190009 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; /* 190010->190011 qadc status register 0 */ vuword qasr1; /* 190012->190013 qadc status register 1 */ vubyte pack01[491]; /* 190014->1901ff */ vuword ccw[64]; /* 190200->190201 conversion command word table */ vuword rjurr[64]; /* 190280->190281 right-justified unsigned result register */ vuword ljsrr[64]; /* 190300->190301 left-justified signed result register */ vuword ljurr[64]; /* 190380->190381 left-justified unsigned result register */ } qadcstruct ;

25 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 128 64Mhz -> 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 28-16 */ 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 27.6.8.1*/ 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 *********************************************************************/


Download ppt "NetBurner Analog to Digital Converter MCF5282 ColdFire Microcontroller User’s manual."

Similar presentations


Ads by Google