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