Another of my random projects
Now that Basic Micro has the BAP40 for sale and they sell a few boards that they plug into, I thought I would give one a try to see what all I need to change to make it work on one of my robots. I thought also since Basic Micro does not currently have a spec sheet out for this big guy I would post some of the information I have found. FYI - I purchased one of their Lab boards to do this.
First here is the pin out for the BAP 40, this came from Nathan (AcidTech):
[code]Pro40 pin outs are:
P0(P50/WKP0)<->(PB0/AN0)
P1(P51/WKP1)<->(PB1/AN1)
P2(P52/WKP2)<->(PB2/AN2)
P3(P53/WKP3)<->(PB3/AN3)
P4(P54/WKP4)
P5(P55/WKP5/ADTRG)
P6(P56/SDA)<->(P86 on RevD)
P7(P57/SCL)<->(P85 on RevD)
P8(P60/FTIOA0)
P9(P61/FTIOB0)<->(P74/TMRIV)
P10(P62/FTIOC0)
P11(P63/FTIOD0)
P12(P64/FTIOA1)
P13(P65/FTIOB1)<->(P70/SCK3_2)
P14(P66/FTIOC1)<->(P71/RXD_2)
P15(P67/FTIOD1)<->(P72/TXD_2)
P16(P30)
P17(P31)
P18(P32)
P19(P33)
P20(P34)
P21(P35)
P22(P36)
P23(P37)
P24(P10/TMOW)
P25(P11/PWM)
P26(P12)
P27(P23)
P28/AX0(P14/IRQ0)<->(PB7/AN7)
P29/AX1(P15/IRQ1/TMIB1)<->(PB6/AN6)
P30/AX2(P16/IRQ2)<->(PB5/AN5)
P31/AX3(P17/IRQ3/TRGV)<->(PB4/AN4)
Thats as close to 4 8bit ports as it is possible to get on the H8-3687. Also S_IN and S_OUT are TXD and RXD.
[/code]
An earlier question I had was where the AX0-3 pins were in relation to the Pin numbers as well as how the other pins were added.
While the Bap28 is currently based on the H8/3694 processor, the Bap40 is based on the H8/3687 and as such there are some differences I will have to take into account when I try converting the code to run on it.
Some of these include:
The Bap40 runs at 20mhz instead of 16mhz, so timing loops need to change. Also some commands like HSERVO are impacted on it. That is the value you pass to HSERVO will change as this value directly relates to the processor speed. For most of our programs this should be easy as we will simply need to change a constant for a modifier between degrees and the HServo value.
HSerial: the good news is this chip has two hardware serial ports. The main HSERIAL is now on S_IN and S_OUT. The second one is on P14 and P15. So if you use hserial on these pins will need to change to hserial2.
Edit:
Analog pins: As Nathan mentioned AX0-3 are now P28-P31
Interrupts: If you are using interrupts like IRQ2, the physical pin numbers has changed.
Timers: If you are using any of the timers, this will probably impact your code. That is the BAP28 has timers: A(8), V(8), W(16) and the BAP40 has timers: B1(8), V(8), Z(2 channels of 16). Hservo on Bap28 uses W timer and on Bap40 I believe uses Channel 0 of Z timer.
Edit: The H8 the Bap40 uses has the capabilities of a Real Time Clock, but this would require an external 32.768khz crystal. Without the Crystal the RTC can be used as another 8 bit timer.
ā¦
It would be nice to be able to have code that conditionally compiles for both chips. I think I may have found a way. That is we can test for the existence of one of the defines for system variables for each platform. Something like:
[code]#ifdef TCNT
; BAP28
ONASMINTERRUPT TIMERWINT, HANDLE_TIMERW_ASM
TCRW = 0x30 ; Set the counter to clock/8 which is the slowest we can set it
TMRW = 0x80 ; Start timer
enable TIMERWINT_OVF
#else
;BAP40
ONASMINTERRUPT TIMERZ1INT, HANDLE_TIMERZ_ASM
; set the appropriate values
TCR_1 = 0x3 ; clock divided by 8
TSTR.bit1 = 1 ; start clock 1
TCNT_1 = 0 ; initialize to zero
enable TIMERZ1INT_OVF
#endif
[/code]
So I may try hosting this board on one of the robots, either Rover or CHR-3 and see if I can get it up and running or at least walking or driving⦠May take awhile as I have more projects than time.
Edited: 10/13 Added in more information about HSERIAL and RTC
Kurt