Menu

ADC avr 328p

Help
wn
2017-12-17
2017-12-21
  • wn

    wn - 2017-12-17

    Having trouble with ADC on a mega328p. I can get the conversion to work in free running mode, however it appears that the Digital Outputs which are part of PORTC are affected by this mode of ADC. I have one dedicated analog in on PORTC.3. Did not know what register bits need to be flipped to correct this issue.

     
    • Anobium

      Anobium - 2017-12-17

      @WN What method are you using? ReadAD? ReadAD10?

       
  • wn

    wn - 2017-12-17

    I did get it figured out. I ended up using ReadAD10 and it works fine. I was trying the free running mode off of a forum post and it was a bit of a problem. On another note, I really could use some help getting a Pin Interrupt working on a mega328pb. I have already modified the mega328p chip file to include the PORTE pins however changing it to allow for the Pin Interrupts on PCINT25 and PCINT27 which are PortE.1 and PortE.3 respectively is a real challenge. Any thoughts?

    Thanks!

     
  • William Roth

    William Roth - 2017-12-17

    @Wn

    As you are aware ATMega328BP is not currently supported by Great Cow Basic. There is no proper chipdata file at this time. I imagine that generating a datafile for this chip will take some time and is likely something that Hugh or Evan will need to do as time allows.

    In regards to a pin change interrupt on PortE pins, the datasheet has conflicting information. In one place it indicates PCINT24-27 are supported, yet there is no PMSKx register to support them and no pin change interrupt flag bit in PCIR register for anything above PCINT23.

    My suggestion at this time is to modify your project/code as needed to use interrupts on supported pins. If this is not possible then you will need to wait on a proper chipdata file.

    You may also want to post a formal request for a chip datafile in the "Chip Files Problems" forum..
    Something like:

            Request: Chip Data File for ATMega328PB
    
     
    • wn

      wn - 2017-12-18

      In looking at the datasheet. I have found that there is a PMSK3 register (0x73) that are for PCINT24-27.I tried modifying the DAT file myself, obviously understanding the risks. I was able to get the code to compile. However if I tried to set the following bits it created unpredicatble behaviour.

      PCICR.PCIE3 = 1 'Enables interrupts on pin group PCINT24..27 & maps them to PCINT3
      PCMSK3.PCINT25 = 1 'Enables specific interrupt PCINT25, PORTE.1
      PCMSK3.PCINT27 = 1 'Enables specific interrupt PCINT19, PORTE.3

      On interrupt PinChange3 Call Encoder_Interrupt

      not sure if I am on the right track or if this the correct notation to use in gcbasic to enable these bits.Do I need to alias them?

      Thanks.

       
      • wn

        wn - 2017-12-18

        I did get it working. I needed to add the correct address for PCINT3 which ties back to PinChange3 in gcbasic.

         
  • William Roth

    William Roth - 2017-12-18

    I just searched the ATMega328BP Datasheet again and could not find any reference to PCMSK3.

    "PCMSK2" is referenced on page 82 but no PCMSK3 anywhere in the datasheet. Perhaps you have a different datasheet?

     
  • wn

    wn - 2017-12-20

    Sorry for the delay. I am using a 328PB not sure what the 328BP is, have not looked at it so I believe you are viewing the incorrect data sheet.

     
  • William Roth

    William Roth - 2017-12-20

    "328BP" was obvioulsy a typo.

    Had you followed the link I provided you would have seen that I am clearly looking at the latest datasheet for ATMega328PB. This is the official Microchip version Please dowmnload it and then search this datasheet for PCMSK3. It is not there unless I missed it.

    Is this the same datasheet that you have?.

    If not then please provide a link to the datasheet that you are looking at. And please tell me what page where register "PMSK3" is described.

    t is possible that Microchip has incorrect / missing data in the datashheet. Perhaps you have an older Atmel version produced before Microchip took over. We will need the correct datasheet/nformation in order create a proper chip data file.

    William

     
  • wn

    wn - 2017-12-20

    I am attaching the datasheet that I have. PCMSK3 can be found on p414 as in the attached image.
    Also, I used the INC file for the 328pb from Atmel Studio 7.0 as a reference as well. I appreciate the feeback and sorry for the confusion.

     
  • wn

    wn - 2017-12-20

    Here is the page image with PCMSK3

     
  • William Roth

    William Roth - 2017-12-21

    Thanks,

    As suspected, Microchip messed up the 328PB Datasheet when it was converted to Microchip format

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.