Jump to content

Bo_DK

EstablishedMember
  • Content Count

    8
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Bo_DK

  • Rank
    Newbrie

Profile Information

  • Location
    Copenhagen, Denmark
  1. Hi Have you changed ther Target PIC in the compiler?
  2. Sure: Check out similar topic from Nov. 15 2002,15:49. Bo
  3. Hello Hmm, I thought so but could not get it to work. Believe me I tried for at least ten hours without bank selection. Then I tried to comment it out and then it still worked. I must add, however, that I upgraded from 2.1.6 to 2.1.8 in between without removing 2.1.6 but just installed 2.1.8 ontop. Then I removed everything and installed 2.1.8 from scratch and now everything works the way it is supposed to. Bo_DK
  4. Like in many other cases of life it is simple when you know how to. I embarked on an identical mission two nights ago and managed to get it to work today. See my P2C program below. Program Test876; #pragma CLOCK_FREQ 4000000 // Change to match xtal frequency ASM __config _XT_OSC & _WDT_OFF & _PWRTE_ON & _BODEN_OFF & _LVP_OFF & _CPD_OFF & _WRT_ENABLE_OFF & _DEBUG_OFF & _CP_OFF Var ADCon0@0x1F,ADCon1@0x9F, // ADC registers ADResH@0x1E,ADResL@0x9E:char; Begin Disable_Interrupt('GIE'); // Initialization of registers Set_Tris_A(11111111b); // Analogue input on PortA_01 Set_Tris_B(00000110b); // Input switches selecting ADC ch. and H/L, PortB_21 Set_Tris_C(00000000b); // ADC result is displayed on PortC // ADC Setup --- see datasheet page 113 -> for more information ---------------------------------------- // Configure ADC module //Set_Bit(STATUS,'RP0'); // Set Data Mem Bank 1 ADCon1:=10000000b; // Result left or right justified (ADCon1_7) // Analogue pins/voltage ref and digital I/O (ADCon1_3210) // ADCon1_654 not used //Clear_Bit(STATUS,'RP0'); // Set Data Mem Band 0 ADCon0:=01000001b; // ADC conversion clock (ADCon0_76) // ADC input channel (ADCon0_543) // Turn ADC on (ADCon0_0) // ADCon0_1 not used While 1 do begin If Input_Pin_port_B(2)=0 then Clear_Bit(ADCon0,3); // Select RA0 else Set_Bit(ADCon0,3); // Select RA1 Set_bit(ADCon0,2); // Start ADC conversion, ADCon0_2 = 1 While ((ADCon0 and 4)=4) do nop; // ADC conversion complete ones ADCon0_2 = 0 If Input_pin_port_B(1)=0 then // Lower part of result is default begin //Set_Bit(Status,'RP0'); // Set Data Mem Bank 1 Output_Port_C(ADResL); // Show low order result on PortC //Clear_Bit(Status,'RP0'); // Set Data Mem Bank 0 end; else Output_Port_C(ADResH); // Show high order result on PortC Delay_ms(10); end; End. Regards Bo_DK
  5. Hello Started on a new MCU last night, the 16F876 to be precise, since I wanted to use the ADC functionality. However, my question is quite general I think, and not just related to the ADC registers (ADCON0 and ~1 and ADRESL and ~H). Do I really need to switch bank to access a variable that has already been assigned to an absolute address? I have tried for several hours without success until I found out that selecting the bank might do the trick. It sure did, but am I missing out on something. I mean why can I not get access to the absolute addressed variable without selecting the bank? Is there a trick I have not yet discovered - quite new to PIC programming. Bo_DK
  6. Hi Do all of them work? E.g. _XT_OSC is not known in P2C. Warning: Not known opcode '__config _XT_OSC ' Bo_DK
  7. Hello all Not even sure if this is the right place to post this. But could not find any P2C forum. I wonder, however, if I am the only one who only uses the P2C compiler/IDE. I am a keen hobbyist who, just, happened to learn Pascal some odd years ago and is quite happy with that. But I do feel a bit alone sometimes. And if I am the only one it is a bit hard to ask for a lot of feature and change requests. Bo ???
×
×
  • Create New...