EasyPic v7 and BarGraph Click Need Assistance.

General discussion on mikroElektronika development boards.
Post Reply
Author
Message
paul.fowler@gmail.com
Posts: 4
Joined: 20 Nov 2023 06:29

EasyPic v7 and BarGraph Click Need Assistance.

#1 Post by paul.fowler@gmail.com » 02 Dec 2023 08:17

Disclaimer, this is my first use of a "Click" on the board, so I could be missing something dumb.

Setup:
  • mikroBasic Pro for PIC v.7.6.0 - Licensed
  • PIC18F45K22, HS, 4x PLL enabled. 32 MHz. Everything else in the default setting on "Edit Project"
  • Program: BarGraph 3 click Example basic (mbas) program. (It is the click with 5 horizonal bars) -> "The library initializes and defines SPI bus driver and drivers that offer a choice for writing data in registers and reading data from registers. The library includes functions for logging values on the BarGraph display. The user can enable and disable the chip with the function bargraph3_enable(), which is supported in the library."
  • I set the project edit search path to the "Uses and pic" folder of the example. I also set it to the "uses" folder of the mikroBUS BDF API
  • I change the mbas file in the BDF API to "easypic_v7_P18F45K22.mbas"
  • Build, link, and program with no errors. (I have programmed and debugged other basic files that I wrote myself for LCD / LEDs, and so far this seems to be the same)
  • All the pull-up and pull-down selector switches are in the middle position.

Symptoms:
  • It does not work, for one. The bars do flash on for a second with power on, then the bars remain off.
  • Examining the pins on the microbus (which is in slot 1).
  • - 3.3V / 5V / GND are all working as expected.
  • - PWM (RC0), INT (RB0), RST (RE1), and CS (RE0) appear to have a logical 1.
  • - Everything else appears to be logical 0

I have reviewed the user manual for the board, and it doesn't appear that I need to change any switches...
For my first click, using the easyPIC v7 board and an example program, what am I missing here? And thank you very much in advance for your help.

Paul
Xoilac TV Official - Kênh Xôi Lạc TV chính thức phát sóng trực tiếp bóng đá hàng đầu Việt Nam. Website: https://xoilac365v.com/

paul.fowler@gmail.com
Posts: 4
Joined: 20 Nov 2023 06:29

Re: EasyPic v7 and BarGraph Click Need Assistance.

#2 Post by paul.fowler@gmail.com » 04 Dec 2023 16:44

This is still a problem, but let me go through more of what I have discovered and documented.

I discovered that:
- the board works on MicroBus 2, so the click board is fine.
- I can get +volts to each pin on MicroBus 1, so it does appear that is o.k.
- So, next I check config bits. I may be configured incorrectly, but I did put P2B on RC0.
- I don't think PWM is working on the first MicroBus, but I don't think that matters either way

Here is the pinout of MicroBus 1 and MicroBus 2:

Code: Select all

' Dimmable with the PWM signal applied over the mikroBUS™ PWM pin.
' Interface: GPIO,PWM,SPI
'
' Notes         | Pin | # |      | MB1 | MB2 |#| Pin | #  | MB1 | MB2 | PIN | Notes
' ----------------------------------------------------------------------------------------------------------
' Output Enable | OE  | 1 | AN   | RA2 | RA3 |#| PWM | 16 | RC0 | RC1 | PWM | PWM dimming
' Data Clear    | RST | 2 | RST  | RE1 | RE2 |#| INT | 15 | RB0 | RB1 | INT |
' Latch IN      | CS  | 3 | CS   | RE0 | RA5 |#| RX  | 14 | RC7 | RC7 | N/A |
' SPI Clock     | SCK | 4 | SCK  | RC3 | RC3 |#| TX  | 13 | RC6 | RC6 | N/A |
'               | N/A | 5 | MISO | RC4 | RC4 |#| SCL | 12 | RC3 | RC3 | N/A |
' SPI IN        | SDI | 6 | MOSI | RC5 | RC5 |#| SDA | 11 | RC4 | RC4 | N/A |
' Power supply  | 3V3 | 7 | 3.3V |     |     |#| 5V  | 10 |     |     | 5V  | Left LED for 3.3, right for 5
' Ground        | GND | 8 | GND  |     |     |#| GND | 9  |     |     | GND | Ground
' ----------------------------------------------------------------------------------------------------------
And more notes relative to my chip:

Code: Select all

' For the P18F45K22:

' The Output Enable pin (#OE) is routed to the AN pin of the mikroBUS™, and it is labeled as OE.
' If this pin is at the HIGH logic level, the outputs Q0 to Q7S of the 74HC595 IC will 
' be set at HIGH-Z (high impedance mode) meaning that they will become disconnected.
'  Memory content and the logic states at the output pins will be unaffected, meaning that 
' the OE can be used to turn the segments of the bar graph on or off without affecting their states
' Output Enable : AN  : RA2 = RA2/C2IN+/AN2/DACOUT/VREF
' Output Enable : AN  : RA3 = RA3/C1IN+/AN3/VREF+

' The #MR pin is used to clear the data in the internal storage register of the 74HC595 IC. 
' The LOW logic level on this pin will clear the content of this storage register, 
' but it will not turn off the outputs which are already activated. 
' The #MR pin is routed to the RST pin of the mikroBUS™
' Data Clear    : RST : RE1 = RE1/P3B/AN6
' Data Clear    : RST : RE2 = RE2/CCP5/AN7

' After the data word has been clocked in, the master SPI clock should be stopped, 
' and the CS pin should be driven to a HIGH logic level
' The CS pin of the mikroBUS™ is routed to the STCP pin of the 74HC595 IC. 
' A rising edge on the STCP input pin of the 74HC595 IC will latch the data from the 
' internal storage register to the output pins, changing the states of its parallel 
' output pins (Q0 to Q7). If a specific bit in the internal storage is 0, 
' the state on the appropriate pin of the 74HC595 IC will become LOW. With their anodes 
' connected to the positive voltage level already (provided that the P-type MOSFET is open), 
' the segment will be lit. This means that the logical 0 lights up a segment, while 1 turns it off.
' Latch IN      : CS  : RE0 = RE0/?P3A?/?CCP3?/AN5
' Latch IN      : CS  : RA5 = RA5/C2OUT/SRNQ/SS1/HLVDIN/AN4

' The clock is used with the SPI interface
' SPI Clock     : SCK : RC3 = ...

' 8-bit data is loaded into the internal registry of this chip through the SPI interface
' Five bits of information are pushed through the serial data input pin (DS) of the 74HC595 IC
' The construction of the SPI interface is such that it operates with 8-bit long words, 
' so the whole data word needs to be clocked in before it is latched on the output. 
' However, the values of the bits that correspond to the non-connected pins of the 74HC595 IC will be disregarded.
' SPI IN        : SDI : RC5 = ...

' The common anode is connected to the PWM pin of the microbus via the P-type MOSFET, which can use the PWM signal from the microcontroller to change the intensity of the display
' PWM Dimming   : PWM : RC0 = RC0/?P2B?/?T3CKI?/T3G/T1CKI/SOSCO, [P2B needs CONFIG3H Bit 5 to 0]  CONFIG3H Default = BF, needs 9F
' PWM Dimming   : PWM : RC1 = RC1/P2A/?CCP2?/SOSCI
Here is most the relevant source code from the example for MicroBus 1. I checked variables aaaa - aaae and they all came back 0 or OK

Code: Select all



const
    _BARGRAPH3_SPI_CFG as uint32_t[4] = (_SPI_MASTER_OSC_DIV64, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH)

sub function  bargraph3_pwmInit(dim freq as uint16_t) as uint32_t 
    PWM1_Init(5000)
    result = 0 
end sub

sub procedure bargraph3_pwmSetDuty(dim duty as uint16_t) 
    PWM1_Set_Duty(duty)
end sub

sub procedure bargraph3_pwmStart() 
    PWM1_Start()
end sub

sub procedure bargraph3_pwmStop() 
    PWM1_Stop()
end sub

...

main:

    aaaa = mikrobus_gpioInit(_MIKROBUS1, _MIKROBUS_CS_PIN, _GPIO_OUTPUT)
    aaab = mikrobus_gpioInit(_MIKROBUS1, _MIKROBUS_RST_PIN, _GPIO_OUTPUT)
    aaac = mikrobus_gpioInit(_MIKROBUS1, _MIKROBUS_PWM_PIN, _GPIO_OUTPUT)
    aaad = mikrobus_gpioInit(_MIKROBUS1, _MIKROBUS_AN_PIN, _GPIO_OUTPUT)
    aaae = mikrobus_spiInit(_MIKROBUS1, @_BARGRAPH3_SPI_CFG[0])
    
    bargraph3_spiDriverInit(T_BARGRAPH3_P(@_MIKROBUS1_GPIO), T_BARGRAPH3_P(@_MIKROBUS1_SPI))
    Delay_100ms()
    bargraph3_enable(_BARGRAPH3_DEVICE_ENABLE)
    Delay_100ms()
    bargraph3_pwmInit(100) 
    bargraph3_pwmSetDuty(30000) 
    bargraph3_pwmStart() 
    Delay_100ms() 

        bargraph3_display(_BARGRAPH3_INCREASE_LED, _BARGRAPH3_DIRECTION_BOTTOM_TO_TOP, bargraph_cnt) 

Any help is sooooo, appreciated, as I have put hours of time into trying to make the click work on MicroBus 1.

Thank you for evey looking at this.
Paul
Xoilac TV Official - Kênh Xôi Lạc TV chính thức phát sóng trực tiếp bóng đá hàng đầu Việt Nam. Website: https://xoilac365v.com/

paul.fowler@gmail.com
Posts: 4
Joined: 20 Nov 2023 06:29

Re: EasyPic v7 and BarGraph Click Need Assistance.

#3 Post by paul.fowler@gmail.com » 10 Dec 2023 10:47

NEW INFORMATION?

So, C0 or PMW is always high for MicroBus 1. I can't get it to go low. Therefore the bars are not showing?
Looking back at the PIC18F45K22 OR the EasyPic v7 board, any reason this might be the case?
I can set ANSEL, TRIS, PORT on C0, but makes no difference. It is high at C0 on the Microbus 1.
I am stumped by that, as it appears to be a localized issue.
This issue really stumps me.
Xoilac TV Official - Kênh Xôi Lạc TV chính thức phát sóng trực tiếp bóng đá hàng đầu Việt Nam. Website: https://xoilac365v.com/

paul.fowler@gmail.com
Posts: 4
Joined: 20 Nov 2023 06:29

Re: EasyPic v7 and BarGraph Click Need Assistance.

#4 Post by paul.fowler@gmail.com » 11 Dec 2023 04:02

I eventually found my solution, although I don't fully understand "why".

The bargraph example will not work "as is" for my board / chip combo from Mikro. After all the initialization has occurred, TRISC0_bit = 1 made it work. Why? I don't know as I sort of stumbled upon it. I knew 75% that C0 PWM was the problem pin, so I was heavily playing with that pin in code and I stumbled on the answer. It is a conflict with something, somewhere, somehow, I guess. It is something the bargraph library and examples don't account for. Oh well, at least it is not the board.
Xoilac TV Official - Kênh Xôi Lạc TV chính thức phát sóng trực tiếp bóng đá hàng đầu Việt Nam. Website: https://xoilac365v.com/

Post Reply

Return to “Development Boards”